home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1993 July / InfoMagic USENET CD-ROM July 1993.ISO / sources / misc / volume8 / gnuplot1.10A / part04 < prev    next >
Encoding:
Text File  |  1989-09-09  |  60.9 KB  |  2,552 lines

  1. Newsgroups: comp.sources.misc
  2. From: allbery@uunet.UU.NET (Brandon S. Allbery - comp.sources.misc)
  3. Subject: v08i038: GnuPlot v1.10A (part 4 of 7)
  4. Reply-To: canoaf@ntvax.UUCP (Augustine Cano)
  5.  
  6. Posting-number: Volume 8, Issue 38
  7. Submitted-by: canoaf@ntvax.UUCP (Augustine Cano)
  8. Archive-name: gnuplot1.10A/part04
  9.  
  10. [OOPS!!!  I had to patch these after receiving them -- and managed to lose the
  11. name of the person who submitted them in the process.  Duh.  The name shown
  12. is a "best guess".  Submitter, please correct me.  ++bsa]
  13.  
  14. #! /bin/sh
  15. # This is a shell archive.  Remove anything before this line, then unpack
  16. # it by saving it into a file and typing "sh file".  To overwrite existing
  17. # files, type "sh file -c".  You can also feed this as standard input via
  18. # unshar, or by typing "sh <file", e.g..  If this archive is complete, you
  19. # will see the following message at the end:
  20. #        "End of archive 4 (of 7)."
  21. # Contents:  plot.c plot.h polar.dem postscpt.trm qms.trm readme.tc
  22. #   regis.trm scanner.c selanar.trm shar simple.dem standard.c tek.trm
  23. #   term.c
  24. # Wrapped by allbery@uunet on Sat Sep  9 13:47:22 1989
  25. PATH=/bin:/usr/bin:/usr/ucb ; export PATH
  26. if test -f 'plot.c' -a "${1}" != "-c" ; then 
  27.   echo shar: Will not clobber existing file \"'plot.c'\"
  28. else
  29. echo shar: Extracting \"'plot.c'\" \(5472 characters\)
  30. sed "s/^X//" >'plot.c' <<'END_OF_FILE'
  31. X/*
  32. X *
  33. X *    G N U P L O T  --  plot.c
  34. X *
  35. X *  Copyright (C) 1986, 1987  Thomas Williams, Colin Kelley
  36. X *
  37. X *  You may use this code as you wish if credit is given and this message
  38. X *  is retained.
  39. X *
  40. X *  Please e-mail any useful additions to vu-vlsi!plot so they may be
  41. X *  included in later releases.
  42. X *
  43. X *  This file should be edited with 4-column tabs!  (:set ts=4 sw=4 in vi)
  44. X *
  45. X *  The Turbo C code was supplied by William E Wilson, 1988-1989
  46. X *
  47. X */
  48. X
  49. X#include <stdio.h>
  50. X#include <setjmp.h>
  51. X#include <signal.h>
  52. X#include "plot.h"
  53. X
  54. X/* on some compilers (Turbo C) interrupt is a reserved word */
  55. X#ifdef MSDOS               
  56. X#define interrupt intrrtn  /*something different*/
  57. X#endif
  58. X
  59. Xchar *getenv(),*strcat(),*strcpy(),*strncpy();
  60. X
  61. Xextern char input_line[];
  62. Xextern FILE *outfile;
  63. Xextern int term;
  64. Xextern struct termentry term_tbl[];
  65. X
  66. X#ifndef STDOUT
  67. X#define STDOUT 1
  68. X#endif
  69. X
  70. Xjmp_buf env;
  71. X
  72. Xstruct value *integer(),*complex();
  73. X
  74. X
  75. Xextern f_push(),f_pushc(),f_pushd(),f_call(),f_lnot(),f_bnot(),f_uminus()
  76. X        ,f_lor(),f_land(),f_bor(),f_xor(),f_band(),f_eq(),f_ne(),f_gt(),f_lt(),
  77. X        f_ge(),f_le(),f_plus(),f_minus(),f_mult(),f_div(),f_mod(),f_power(),
  78. X        f_factorial(),f_bool(),f_jump(),f_jumpz(),f_jumpnz(),f_jtern();
  79. X
  80. Xextern f_real(),f_imag(),f_arg(),f_conjg(),f_sin(),f_cos(),f_tan(),f_asin(),
  81. X        f_acos(),f_atan(),f_sinh(),f_cosh(),f_tanh(),f_int(),f_abs(),f_sgn(),
  82. X        f_sqrt(),f_exp(),f_log10(),f_log(),f_besj0(),f_besj1(),f_besy0(),f_besy1(),
  83. X#ifdef GAMMA
  84. X        f_gamma(),
  85. X#endif
  86. X        f_floor(),f_ceil();
  87. X
  88. X
  89. Xstruct ft_entry ft[] = {        /* built-in function table */
  90. X
  91. X/* internal functions: */
  92. X        {"push", f_push},       {"pushc", f_pushc},     {"pushd", f_pushd},
  93. X        {"call", f_call},       {"lnot", f_lnot},       {"bnot", f_bnot},
  94. X        {"uminus", f_uminus},                                   {"lor", f_lor},
  95. X        {"land", f_land},       {"bor", f_bor},         {"xor", f_xor},
  96. X        {"band", f_band},       {"eq", f_eq},           {"ne", f_ne},
  97. X        {"gt", f_gt},           {"lt", f_lt},           {"ge", f_ge},
  98. X        {"le", f_le},           {"plus", f_plus},       {"minus", f_minus},
  99. X        {"mult", f_mult},       {"div", f_div},         {"mod", f_mod},
  100. X        {"power", f_power}, {"factorial", f_factorial},
  101. X        {"bool", f_bool},       {"jump", f_jump},       {"jumpz", f_jumpz},
  102. X        {"jumpnz",f_jumpnz},{"jtern", f_jtern},
  103. X
  104. X/* standard functions: */
  105. X        {"real", f_real},       {"imag", f_imag},       {"arg", f_arg},
  106. X        {"conjg", f_conjg}, {"sin", f_sin},             {"cos", f_cos},
  107. X        {"tan", f_tan},         {"asin", f_asin},       {"acos", f_acos},
  108. X        {"atan", f_atan},       {"sinh", f_sinh},       {"cosh", f_cosh},
  109. X        {"tanh", f_tanh},       {"int", f_int},         {"abs", f_abs},
  110. X        {"sgn", f_sgn},         {"sqrt", f_sqrt},       {"exp", f_exp},
  111. X        {"log10", f_log10},     {"log", f_log},         {"besj0", f_besj0},
  112. X        {"besj1", f_besj1},     {"besy0", f_besy0},     {"besy1", f_besy1},
  113. X#ifdef GAMMA
  114. X        {"gamma", f_gamma},
  115. X#endif
  116. X        {"floor", f_floor},     {"ceil", f_ceil},
  117. X        {NULL, NULL}
  118. X};
  119. X
  120. Xstatic struct udvt_entry udv_pi = {NULL, "pi",FALSE};
  121. X/* first in linked list */
  122. Xstruct udvt_entry *first_udv = &udv_pi;
  123. Xstruct udft_entry *first_udf = NULL;
  124. X
  125. X
  126. X
  127. X#ifdef vms
  128. X
  129. X#define HOME "sys$login:"
  130. X
  131. X#else /* vms */
  132. X#ifdef MSDOS
  133. X
  134. X#define HOME "GNUPLOT"
  135. X
  136. X#else /* MSDOS */
  137. X
  138. X#define HOME "HOME"
  139. X
  140. X#endif /* MSDOS */
  141. X#endif /* vms */
  142. X
  143. X#ifdef unix
  144. X#define PLOTRC ".gnuplot"
  145. X#else
  146. X#define PLOTRC "gnuplot.ini"
  147. X#endif
  148. X
  149. X
  150. X#ifdef __TURBOC__
  151. Xvoid interrupt()
  152. X#else
  153. Xinterrupt()
  154. X#endif
  155. X{
  156. X#ifdef MSDOS
  157. X#ifdef __TURBOC__
  158. X  (void) signal(SIGINT, interrupt);
  159. X#else
  160. X    void ss_interrupt();
  161. X    (void) signal(SIGINT, ss_interrupt);
  162. X#endif
  163. X#else
  164. X    (void) signal(SIGINT, interrupt);
  165. X#endif
  166. X    (void) signal(SIGFPE, SIG_DFL);    /* turn off FPE trapping */
  167. X    if (term)
  168. X        (*term_tbl[term].text)();    /* hopefully reset text mode */
  169. X    (void) fflush(outfile);
  170. X    (void) putc('\n',stderr);
  171. X    longjmp(env, TRUE);        /* return to prompt */
  172. X}
  173. X
  174. X
  175. Xmain()
  176. X{
  177. Xregister FILE *plotrc;
  178. Xregister char *gnuterm=NULL;
  179. Xstatic char home[sizeof(PLOTRC)+80];
  180. X
  181. X    setbuf(stderr,(char *)NULL);
  182. X#ifdef VMS
  183. X    outfile = stdout; /* never close stdout--even if duped. */
  184. X#else
  185. X    outfile = fdopen(dup(STDOUT),"w");
  186. X#endif
  187. X    (void) complex(&udv_pi.udv_value, Pi, 0.0);
  188. X    show_version();
  189. X    init();  /* Can set term if it wishes. */
  190. X
  191. X/* thanks to osupyr!alden (Dave Alden) for the GNUTERM code */
  192. X
  193. X    if (!(gnuterm = getenv("GNUTERM")) && term == 0)
  194. X        gnuterm = TERM;
  195. X    if (gnuterm != NULL)
  196. X        (void) strcat(input_line,gnuterm); /* input_line has "set term " */
  197. X    else
  198. X        input_line[0] = '\0';   /* No SET TERM command needed. */
  199. X
  200. X    if (!setjmp(env))                /* come back here from printerror() */
  201. X        do_line();
  202. X
  203. X    if (!setjmp(env)) {
  204. X#ifdef MSDOS 
  205. X#ifdef __TURBOC__
  206. X        (void) signal(SIGINT, interrupt);    /* go there on interrupt char */
  207. X#else
  208. X        void ss_interrupt();
  209. X        save_stack();                /* work-around for MSC 4.0/MSDOS 3.x bug */
  210. X        (void) signal(SIGINT, ss_interrupt);
  211. X#endif
  212. X#else /* MSDOS */
  213. X        (void) signal(SIGINT, interrupt);    /* go there on interrupt char */
  214. X#endif /* MSDOS */
  215. X        if (!(plotrc = (fopen(PLOTRC,"r")))) {
  216. X#ifdef vms
  217. X            (void) strncpy(home,HOME,sizeof(home));
  218. X            plotrc = fopen(strcat(home,PLOTRC),"r");
  219. X#else /* vms */
  220. X            (void) strcat(strncpy(home,getenv(HOME),sizeof(home)),"/");
  221. X            plotrc = fopen(strcat(home,PLOTRC),"r");
  222. X#endif /* vms */
  223. X        }
  224. X        if (plotrc)
  225. X            load_file(plotrc);
  226. X    }
  227. X
  228. Xloop:    com_line();
  229. X        goto loop;
  230. X}
  231. END_OF_FILE
  232. if test 5472 -ne `wc -c <'plot.c'`; then
  233.     echo shar: \"'plot.c'\" unpacked with wrong size!
  234. fi
  235. # end of 'plot.c'
  236. fi
  237. if test -f 'plot.h' -a "${1}" != "-c" ; then 
  238.   echo shar: Will not clobber existing file \"'plot.h'\"
  239. else
  240. echo shar: Extracting \"'plot.h'\" \(5830 characters\)
  241. sed "s/^X//" >'plot.h' <<'END_OF_FILE'
  242. X/*
  243. X *
  244. X *    G N U P L O T  --  plot.h
  245. X *
  246. X *  Copyright (C) 1986, 1987  Thomas Williams, Colin Kelley
  247. X *
  248. X *  You may use this code as you wish if credit is given and this message
  249. X *  is retained.
  250. X *
  251. X *  Please e-mail any useful additions to vu-vlsi!plot so they may be
  252. X *  included in later releases.
  253. X *
  254. X *  This file should be edited with 4-column tabs!  (:set ts=4 sw=4 in vi)
  255. X */
  256. X
  257. X#define PROGRAM "G N U P L O T"
  258. X#define PROMPT "gnuplot> "
  259. X#define SHELL "/bin/sh"        /* used if SHELL env variable not set */
  260. X
  261. X#ifdef vms
  262. X#define HELP  "gnuplot "
  263. X#else /* vms */
  264. X#define HELP  "/usr/local/bin/help gnuplot"
  265. X#endif /* vms */
  266. X
  267. X#define SAMPLES 160            /* default number of samples for a plot */
  268. X#define ZERO    1e-8        /* default for 'zero' set option */
  269. X
  270. X#ifdef __TURBOC__
  271. X#ifndef PC
  272. X#define PC 1
  273. X#endif
  274. X#endif
  275. X
  276. X#ifdef PC
  277. X#define TERM "egalib"
  278. X#else
  279. X#ifdef UNIXPC
  280. X#define TERM "unixpc"
  281. X#else
  282. X#define TERM "tek40xx"        /* put your most common term type here! */
  283. X#endif 
  284. X#endif
  285. X
  286. X#define TRUE 1
  287. X#define FALSE 0
  288. X
  289. X#define Pi 3.141592653589793
  290. X
  291. X#define MAX_POINTS 1
  292. X#define MAX_LINE_LEN 255    /* maximum number of chars allowed on line */
  293. X#define MAX_TOKENS 200
  294. X#define MAX_ID_LEN 20        /* max length of an identifier */
  295. X
  296. X#define MAX_AT_LEN 150        /* max number of entries in action table */
  297. X#define STACK_DEPTH 100
  298. X#define NO_CARET (-1)
  299. X
  300. X
  301. X#ifdef vms
  302. X#define OS "VMS "
  303. X#endif
  304. X
  305. X#ifdef unix
  306. X#define OS "unix "
  307. X#endif
  308. X
  309. X#ifdef MSDOS
  310. X#define OS "MS-DOS "
  311. X#endif
  312. X
  313. X#ifndef OS
  314. X#define OS ""
  315. X#endif
  316. X
  317. X/*
  318. X * note about HUGE:  this number is just used as a flag for really
  319. X *   big numbers, so it doesn't have to be the absolutely biggest number
  320. X *   on the machine.
  321. X *
  322. X * define HUGE here if your compiler doesn't define it in <math.h>
  323. X * example:
  324. X#define HUGE 1e38
  325. X */
  326. X#ifndef HUGE 
  327. X#ifdef HUGE_VAL  /* __TURBOC__ and VMS C ver 3.0 (ansi type compilers) */
  328. X#define HUGE HUGE_VAL
  329. X#else
  330. X#define HUGE 1e38
  331. X#endif
  332. X#endif
  333. X
  334. X#define END_OF_COMMAND (c_token >= num_tokens || equals(c_token,";"))
  335. X
  336. X
  337. X#ifdef vms
  338. X
  339. X#define is_comment(c) ((c) == '#' || (c) == '!')
  340. X#define is_system(c) ((c) == '$')
  341. X
  342. X#else /* vms */
  343. X
  344. X#define is_comment(c) ((c) == '#')
  345. X#define is_system(c) ((c) == '!')
  346. X
  347. X#endif /* vms */
  348. X
  349. X/*
  350. X * If you're memcpy() has another name, define it below as bcopy() is.
  351. X * If you don't have a memcpy():
  352. X#define NOCOPY
  353. X */
  354. X
  355. X#ifdef BCOPY
  356. X#define memcpy(dest,src,len) bcopy(src,dest,len)
  357. X#endif /* BCOPY */
  358. X
  359. X#ifdef vms
  360. X#define memcpy(dest,src,len) lib$movc3(&len,src,dest)
  361. X#endif /* vms */
  362. X
  363. X#define top_of_stack stack[s_p]
  364. X
  365. Xtypedef int BOOLEAN;
  366. Xtypedef int (*FUNC_PTR)();
  367. X
  368. Xenum operators {
  369. X    PUSH, PUSHC, PUSHD, CALL, LNOT, BNOT, UMINUS, LOR, LAND, BOR, XOR,
  370. X    BAND, EQ, NE, GT, LT, GE, LE, PLUS, MINUS, MULT, DIV, MOD, POWER,
  371. X    FACTORIAL, BOOL, JUMP, JUMPZ, JUMPNZ, JTERN, SF_START
  372. X};
  373. X
  374. X#define is_jump(operator) ((operator) >=(int)JUMP && (operator) <(int)SF_START)
  375. X
  376. Xenum DATA_TYPES {
  377. X    INT, CMPLX
  378. X};
  379. X
  380. Xenum PLOT_TYPE {
  381. X    FUNC, DATA
  382. X};
  383. X
  384. Xenum PLOT_STYLE {
  385. X    LINES, POINTS, IMPULSES
  386. X};
  387. X
  388. Xstruct cmplx {
  389. X    double real, imag;
  390. X};
  391. X
  392. Xstruct value {
  393. X    enum DATA_TYPES type;
  394. X    union {
  395. X        int int_val;
  396. X        struct cmplx cmplx_val;
  397. X    } v;
  398. X};
  399. X
  400. Xstruct lexical_unit {    /* produced by scanner */
  401. X    BOOLEAN is_token;    /* true if token, false if a value */ 
  402. X    struct value l_val;
  403. X    int start_index;    /* index of first char in token */
  404. X    int length;            /* length of token in chars */
  405. X};
  406. X
  407. Xstruct ft_entry {        /* standard/internal function table entry */
  408. X    char *f_name;        /* pointer to name of this function */
  409. X    FUNC_PTR func;        /* address of function to call */
  410. X};
  411. X
  412. Xstruct udft_entry {                /* user-defined function table entry */
  413. X    struct udft_entry *next_udf; /* pointer to next udf in linked list */
  414. X    char udf_name[MAX_ID_LEN+1]; /* name of this function entry */
  415. X    struct at_type *at;            /* pointer to action table to execute */
  416. X    char *definition;             /* definition of function as typed */
  417. X    struct value dummy_value;    /* current value of dummy variable */
  418. X};
  419. X
  420. Xstruct udvt_entry {            /* user-defined value table entry */
  421. X    struct udvt_entry *next_udv; /* pointer to next value in linked list */
  422. X    char udv_name[MAX_ID_LEN+1]; /* name of this value entry */
  423. X    BOOLEAN udv_undef;        /* true if not defined yet */
  424. X    struct value udv_value;    /* value it has */
  425. X};
  426. X
  427. Xunion argument {            /* p-code argument */
  428. X    int j_arg;                /* offset for jump */
  429. X    struct value v_arg;        /* constant value */
  430. X    struct udvt_entry *udv_arg;    /* pointer to dummy variable */
  431. X    struct udft_entry *udf_arg; /* pointer to udf to execute */
  432. X};
  433. X
  434. Xstruct at_entry {            /* action table entry */
  435. X    enum operators index;    /* index of p-code function */
  436. X    union argument arg;
  437. X};
  438. X
  439. Xstruct at_type {
  440. X    int a_count;                /* count of entries in .actions[] */
  441. X    struct at_entry actions[MAX_AT_LEN];
  442. X        /* will usually be less than MAX_AT_LEN is malloc()'d copy */
  443. X};
  444. X
  445. Xstruct coordinate {
  446. X    BOOLEAN undefined;    /* TRUE if value off screen */
  447. X#ifdef PC
  448. X    float x, y;            /* memory is tight on PCs! */
  449. X#else
  450. X    double x, y;
  451. X#endif /* PC */
  452. X};
  453. X
  454. Xstruct curve_points {
  455. X    struct curve_points *next_cp;    /* pointer to next plot in linked list */
  456. X    enum PLOT_TYPE plot_type;
  457. X    enum PLOT_STYLE plot_style;
  458. X    char *title;
  459. X    int p_count;                    /* count of points in .points[] */
  460. X    struct coordinate points[MAX_POINTS];
  461. X        /* will usually be less in malloc()'d copy */
  462. X};
  463. X
  464. Xstruct termentry {
  465. X    char *name;
  466. X    unsigned int xmax,ymax,v_char,h_char,v_tic,h_tic;
  467. X    FUNC_PTR init,reset,text,graphics,move,vector,linetype,lrput_text,
  468. X        ulput_text,point;
  469. X};
  470. X
  471. X/*
  472. X * SS$_NORMAL is "normal completion", STS$M_INHIB_MSG supresses
  473. X * printing a status message.
  474. X * SS$_ABORT is the general abort status code.
  475. X from:    Martin Minow
  476. X    decvax!minow
  477. X */
  478. X#ifdef    vms
  479. X#include        <ssdef.h>
  480. X#include        <stsdef.h>
  481. X#define    IO_SUCCESS    (SS$_NORMAL | STS$M_INHIB_MSG)
  482. X#define    IO_ERROR    SS$_ABORT
  483. X#endif /* vms */
  484. X
  485. X#ifndef    IO_SUCCESS    /* DECUS or VMS C will have defined these already */
  486. X#define    IO_SUCCESS    0
  487. X#endif
  488. X#ifndef    IO_ERROR
  489. X#define    IO_ERROR    1
  490. X#endif
  491. END_OF_FILE
  492. if test 5830 -ne `wc -c <'plot.h'`; then
  493.     echo shar: \"'plot.h'\" unpacked with wrong size!
  494. fi
  495. # end of 'plot.h'
  496. fi
  497. if test -f 'polar.dem' -a "${1}" != "-c" ; then 
  498.   echo shar: Will not clobber existing file \"'polar.dem'\"
  499. else
  500. echo shar: Extracting \"'polar.dem'\" \(554 characters\)
  501. sed "s/^X//" >'polar.dem' <<'END_OF_FILE'
  502. X#
  503. X# Show some of the new polar capabilities.
  504. X#
  505. Xset polar
  506. Xset xrange [0:2*pi]
  507. Xplot .5,1,1.5
  508. Xpause -1 "Three circles (with aspect ratio distortion)"
  509. Xplot cos(2*x)
  510. Xpause -1 "Hit return"
  511. Xplot 2*sqrt(cos(x)),-2*sqrt(cos(x))
  512. Xpause -1
  513. Xset offset pi/4,pi/4,0,0
  514. Xplot sin(4*x),cos(4*x)
  515. Xpause -1
  516. Xset yrange [-3:3]
  517. Xplot x/cos(3*x)
  518. Xset autoscale
  519. Xpause -1
  520. Xplot 1-sin(x)
  521. Xpause -1
  522. Xset xrange [0:12*pi]
  523. Xplot 2*x
  524. Xpause -1
  525. Xbutterfly(x)=exp(cos(x))-2*cos(4*x)+sin(x/12)**5
  526. Xset samples 800
  527. Xpause 0 "This is a big one (many samples), be patient..."
  528. Xplot butterfly(x)
  529. Xpause -1
  530. END_OF_FILE
  531. if test 554 -ne `wc -c <'polar.dem'`; then
  532.     echo shar: \"'polar.dem'\" unpacked with wrong size!
  533. fi
  534. # end of 'polar.dem'
  535. fi
  536. if test -f 'postscpt.trm' -a "${1}" != "-c" ; then 
  537.   echo shar: Will not clobber existing file \"'postscpt.trm'\"
  538. else
  539. echo shar: Extracting \"'postscpt.trm'\" \(2014 characters\)
  540. sed "s/^X//" >'postscpt.trm' <<'END_OF_FILE'
  541. X/* thanks to richb@yarra.OZ (Rich Burridge) for the Postscript driver */
  542. X#define PS_XMAX 540
  543. X#define PS_YMAX 720
  544. X
  545. X#define PS_XLAST (PS_XMAX - 1)
  546. X#define PS_YLAST (PS_YMAX - 1)
  547. X
  548. X#define PS_VCHAR (PS_YMAX/30)
  549. X#define PS_HCHAR (PS_XMAX/72)
  550. X#define PS_VTIC (PS_YMAX/80)
  551. X#define PS_HTIC (PS_XMAX/80)
  552. X
  553. X
  554. XPS_init()
  555. X{
  556. X  (void) fprintf(outfile,"%%!\n") ;
  557. X  (void) fprintf(outfile,"/off {36 add} def\n") ;
  558. X  (void) fprintf(outfile,"/mv {off exch off moveto} def\n") ;
  559. X  (void) fprintf(outfile,"/ln {off exch off lineto} def\n") ;
  560. X  (void) fprintf(outfile,"/Times-Roman findfont 12 scalefont setfont\n") ;
  561. X  (void) fprintf(outfile,"0.25 setlinewidth\n") ;
  562. X}
  563. X
  564. X
  565. XPS_graphics()
  566. X{
  567. X  (void) fprintf(outfile,"newpath\n") ;
  568. X}
  569. X
  570. X
  571. XPS_text()
  572. X{
  573. X  (void) fprintf(outfile,"stroke\n") ;
  574. X  (void) fprintf(outfile,"showpage\n") ;
  575. X}
  576. X
  577. X
  578. XPS_linetype(linetype)
  579. Xint linetype ;
  580. X{
  581. X  (void) fprintf(outfile,"stroke [") ;
  582. X  switch ((linetype+2)%7)
  583. X    {
  584. X      case 0 :                                 /* solid. */
  585. X      case 2 : break ;
  586. X      case 1 :                                 /* longdashed. */
  587. X      case 6 : (void) fprintf(outfile,"9 3") ;
  588. X               break ;
  589. X      case 3 : (void) fprintf(outfile,"3") ;            /* dotted. */
  590. X               break ;
  591. X      case 4 : (void) fprintf(outfile,"6 3") ;          /* shortdashed. */
  592. X               break ;
  593. X      case 5 : (void) fprintf(outfile,"3 3 6 3") ;      /* dotdashed. */
  594. X    }
  595. X  (void) fprintf(outfile,"] 0 setdash\n") ;
  596. X}
  597. XPS_move(x,y)
  598. Xunsigned int x,y ;
  599. X{
  600. X  (void) fprintf(outfile,"%1d %1d mv\n",y,x) ;
  601. X}
  602. XPS_vector(x,y)
  603. Xunsigned int x,y ;
  604. X{
  605. X  (void) fprintf(outfile,"%1d %1d ln\n",y,x) ;
  606. X}
  607. XPS_lrput_text(row,str)
  608. Xunsigned int row ;
  609. Xchar str[] ;
  610. X{
  611. X  PS_move(PS_XMAX - PS_HTIC - PS_HCHAR*(strlen(str)+1),
  612. X          PS_VTIC + PS_VCHAR*(row+1)) ;
  613. X  (void) fprintf(outfile,"(%s) show\n",str) ;
  614. X}
  615. X
  616. X
  617. XPS_ulput_text(row,str)
  618. Xunsigned int row ;
  619. Xchar str[] ;
  620. X{
  621. X  PS_move(PS_HTIC, PS_YMAX - PS_VTIC - PS_VCHAR*(row+1)) ;
  622. X  (void) fprintf(outfile,"(%s) show\n",str) ;
  623. X}
  624. X
  625. X
  626. XPS_reset()
  627. X{
  628. X}
  629. X
  630. X
  631. END_OF_FILE
  632. if test 2014 -ne `wc -c <'postscpt.trm'`; then
  633.     echo shar: \"'postscpt.trm'\" unpacked with wrong size!
  634. fi
  635. # end of 'postscpt.trm'
  636. fi
  637. if test -f 'qms.trm' -a "${1}" != "-c" ; then 
  638.   echo shar: Will not clobber existing file \"'qms.trm'\"
  639. else
  640. echo shar: Extracting \"'qms.trm'\" \(1674 characters\)
  641. sed "s/^X//" >'qms.trm' <<'END_OF_FILE'
  642. X#define QMS_XMAX 9000
  643. X#define QMS_YMAX 6000
  644. X
  645. X#define QMS_XLAST (QMS_XMAX - 1)
  646. X#define QMS_YLAST (QMS_YMAX - 1)
  647. X
  648. X#define QMS_VCHAR        120
  649. X#define QMS_HCHAR        75
  650. X#define QMS_VTIC        70
  651. X#define QMS_HTIC        70
  652. X
  653. X
  654. XQMS_init()
  655. X{
  656. X/* This was just ^IOL, but at Rutgers at least we need some more stuff */
  657. X  fprintf(outfile,"^PY^-\n^IOL\n^ISYNTAX00000^F^IB11000^IJ00000^IT00000\n");
  658. X}
  659. X
  660. X
  661. XQMS_graphics()
  662. X{
  663. X    fprintf(outfile,"^IGV\n");
  664. X}
  665. X
  666. X
  667. X
  668. XQMS_text()
  669. X{
  670. X/* added ^-, because ^, after an ^I command doesn't actually print a page */
  671. X/* Did anybody try this code out?  [uhh...-cdk] */
  672. X    fprintf(outfile,"^IGE\n^-^,");
  673. X}
  674. X
  675. X
  676. XQMS_linetype(linetype)
  677. Xint linetype;
  678. X{
  679. Xstatic int width[2+9] = {7, 3, 3, 3, 3, 5, 5, 5, 7, 7, 7};
  680. X/*
  681. X * I don't know about Villanova, but on our printer, using ^V without
  682. X * previously setting up a pattern crashes the microcode.
  683. X * [nope, doesn't crash here. -cdk]
  684. X */
  685. X    static int type[2+9] =  {0, 0, 0, 2, 5, 0, 2, 5, 0, 2, 5};
  686. X    if (linetype >= 9)
  687. X        linetype %= 9;
  688. X    fprintf(outfile,"^PW%02d\n^V%x\n",width[linetype+2], type[linetype+2]); 
  689. X}
  690. X
  691. X
  692. XQMS_move(x,y)
  693. Xint x,y;
  694. X{
  695. X    fprintf(outfile,"^U%05d:%05d\n", 1000 + x, QMS_YLAST + 1000 - y);
  696. X}
  697. X
  698. X
  699. XQMS_vector(x2,y2)
  700. Xint x2,y2;
  701. X{
  702. X    fprintf(outfile,"^D%05d:%05d\n", 1000 + x2, QMS_YLAST + 1000 - y2);
  703. X}
  704. X
  705. X
  706. XQMS_lrput_text(row,str)
  707. Xint row;
  708. Xchar str[];
  709. X{
  710. X    QMS_move(QMS_XMAX-QMS_HTIC-QMS_HCHAR*(strlen(str)+1),
  711. X        QMS_VTIC+QMS_VCHAR*(row+1));
  712. X    fprintf(outfile,"^IGE\n%s\n^IGV\n",str);
  713. X}
  714. X
  715. XQMS_ulput_text(row,str)
  716. Xint row;
  717. Xchar str[];
  718. X{
  719. X    QMS_move(QMS_HTIC*2,QMS_YMAX-QMS_VTIC-QMS_VCHAR*(row+1));
  720. X    fprintf(outfile,"^IGE\n%s\n^IGV\n",str);
  721. X}
  722. X
  723. X
  724. XQMS_reset()
  725. X{
  726. X/* add ^- just in case last thing was ^I command */
  727. X    fprintf(outfile,"^-^,\n");
  728. X}
  729. X
  730. X
  731. END_OF_FILE
  732. if test 1674 -ne `wc -c <'qms.trm'`; then
  733.     echo shar: \"'qms.trm'\" unpacked with wrong size!
  734. fi
  735. # end of 'qms.trm'
  736. fi
  737. if test -f 'readme.tc' -a "${1}" != "-c" ; then 
  738.   echo shar: Will not clobber existing file \"'readme.tc'\"
  739. else
  740. echo shar: Extracting \"'readme.tc'\" \(967 characters\)
  741. sed "s/^X//" >'readme.tc' <<'END_OF_FILE'
  742. XFor those of you that will be compiling this code with Turbo C, there
  743. Xare a few things that you will need to know.  First, this code can only
  744. Xbe compiled with TC 2.0 or higher.  This is because of the special graphics
  745. Xroutines that were utilized.  When compiling it is normal to receive a
  746. Xnumber of warnings.  You should not get any errors though.  The warnings
  747. Xare normally functions not returning values and some warnings about possible
  748. Xincorrect assignments.  The program runs fine in spite of these.
  749. X
  750. XThe other thing that you must do after compiling is to make sure that the
  751. X.BGI files are installed in the subdirectory that the program is to be run
  752. Xfrom.  Even if you put gnuplot on your path, you must have these files in your
  753. Xcurrent subdirectory.  If you want to fully path the program you can change
  754. Xthe init() routine to include the path to the .bgi files.  If you do this,
  755. Xsend the code back to us.
  756. X
  757. XGood Luck and have fun!
  758. X
  759. XWilliam E Wilson
  760. Xwilson@nauvax
  761. END_OF_FILE
  762. if test 967 -ne `wc -c <'readme.tc'`; then
  763.     echo shar: \"'readme.tc'\" unpacked with wrong size!
  764. fi
  765. # end of 'readme.tc'
  766. fi
  767. if test -f 'regis.trm' -a "${1}" != "-c" ; then 
  768.   echo shar: Will not clobber existing file \"'regis.trm'\"
  769. else
  770. echo shar: Extracting \"'regis.trm'\" \(2172 characters\)
  771. sed "s/^X//" >'regis.trm' <<'END_OF_FILE'
  772. X#define REGISXMAX 800             
  773. X#define REGISYMAX 440
  774. X
  775. X#define REGISXLAST (REGISXMAX - 1)
  776. X#define REGISYLAST (REGISYMAX - 1)
  777. X
  778. X#define REGISVCHAR        20      
  779. X#define REGISHCHAR        8        
  780. X#define REGISVTIC        8
  781. X#define REGISHTIC        6
  782. X
  783. XREGISinit()
  784. X{
  785. X    fprintf(outfile,"\033[r\033[24;1H");
  786. X/*                   1     2
  787. X    1. reset scrolling region
  788. X    2. locate cursor on bottom line
  789. X*/
  790. X}
  791. X
  792. X
  793. X/* thanks to calmasd!dko (Dan O'Neill) for adding S(E) for vt125s */
  794. XREGISgraphics()
  795. X{
  796. X    fprintf(outfile,"\033[2J\033P1pS(C0)S(E)");
  797. X/*                   1      2      3    4
  798. X    1. clear screen
  799. X    2. enter ReGIS graphics
  800. X    3. turn off graphics diamond cursor
  801. X    4. clear graphics screen
  802. X*/
  803. X}
  804. X
  805. X
  806. XREGIStext()
  807. X{
  808. X    fprintf(outfile,"\033\\\033[24;1H");
  809. X/*                       1    2
  810. X    1. Leave ReGIS graphics mode
  811. X     2. locate cursor on last line of screen
  812. X*/
  813. X}
  814. X
  815. X
  816. XREGISlinetype(linetype)
  817. Xint     linetype;
  818. X{
  819. X      /* This will change color in order G,R,B,G-dot,R-dot,B-dot */
  820. Xstatic int in_map[9 + 2] = {2, 2, 3, 2, 1, 3, 2, 1, 3, 2, 1};
  821. Xstatic int lt_map[9 + 2] = {1, 4, 1, 1, 1, 4, 4, 4, 6, 6, 6};
  822. X
  823. X    if (linetype >= 9)
  824. X        linetype %= 9;
  825. X    fprintf(outfile, "W(I%d)", in_map[linetype + 2]);
  826. X    fprintf(outfile, "W(P%d)", lt_map[linetype + 2]);
  827. X}
  828. X
  829. X
  830. XREGISmove(x,y)
  831. Xint x,y;
  832. X{
  833. X    fprintf(outfile,"P[%d,%d]",x,REGISYLAST-y,x,REGISYLAST-y);
  834. X}
  835. X
  836. X
  837. XREGISvector(x,y)
  838. Xint x,y;
  839. X{
  840. X    fprintf(outfile,"v[]v[%d,%d]",x,REGISYLAST - y);
  841. X/* the initial v[] is needed to get the first pixel plotted */
  842. X}
  843. X
  844. X
  845. XREGISlrput_text(row,str)
  846. Xint row;
  847. Xchar *str;
  848. X{
  849. X    REGISmove(REGISXMAX-REGISHTIC-REGISHCHAR*(strlen(str)+3),
  850. X        REGISVTIC+REGISVCHAR*(row+1));
  851. X    (void) putc('T',outfile); (void) putc('\'',outfile);
  852. X    while (*str) {
  853. X        (void) putc(*str,outfile);
  854. X        if (*str == '\'')
  855. X            (void) putc('\'',outfile);    /* send out another one */
  856. X        str++;
  857. X    }
  858. X    (void) putc('\'',outfile);
  859. X}
  860. X
  861. X
  862. XREGISulput_text(row,str)
  863. Xint row;
  864. Xchar *str;
  865. X{
  866. X    REGISmove(REGISVTIC,REGISYMAX-REGISVTIC*2-REGISVCHAR*row);
  867. X    (void) putc('T',outfile); (void) putc('\'',outfile);
  868. X    while (*str) {
  869. X        (void) putc(*str,outfile);
  870. X        if (*str == '\'')
  871. X            (void) putc('\'',outfile);    /* send out another one */
  872. X        str++;
  873. X    }
  874. X    (void) putc('\'',outfile);
  875. X}
  876. X
  877. X
  878. XREGISreset()
  879. X{
  880. X    fprintf(outfile,"\033[2J\033[24;1H");
  881. X}
  882. X
  883. X
  884. END_OF_FILE
  885. if test 2172 -ne `wc -c <'regis.trm'`; then
  886.     echo shar: \"'regis.trm'\" unpacked with wrong size!
  887. fi
  888. # end of 'regis.trm'
  889. fi
  890. if test -f 'scanner.c' -a "${1}" != "-c" ; then 
  891.   echo shar: Will not clobber existing file \"'scanner.c'\"
  892. else
  893. echo shar: Extracting \"'scanner.c'\" \(7076 characters\)
  894. sed "s/^X//" >'scanner.c' <<'END_OF_FILE'
  895. X/*
  896. X *
  897. X *    G N U P L O T  --  scanner.c
  898. X *
  899. X *  Copyright (C) 1986, 1987  Colin Kelley, Thomas Williams
  900. X *
  901. X *  You may use this code as you wish if credit is given and this message
  902. X *  is retained.
  903. X *
  904. X *  Please e-mail any useful additions to vu-vlsi!plot so they may be
  905. X *  included in later releases.
  906. X *
  907. X *  This file should be edited with 4-column tabs!  (:set ts=4 sw=4 in vi)
  908. X */
  909. X
  910. X#include <stdio.h>
  911. X#include <ctype.h>
  912. X#include "plot.h"
  913. X
  914. Xextern BOOLEAN screen_ok;
  915. X
  916. X#ifdef vms
  917. X
  918. X#include stdio
  919. X#include descrip
  920. X#include errno
  921. X
  922. X#define MAILBOX "PLOT$MAILBOX"
  923. X#define pclose(f) fclose(f)
  924. X
  925. X#endif /* vms */
  926. X
  927. X
  928. X#define isident(c) (isalnum(c) || (c) == '_')
  929. X
  930. X#ifndef STDOUT
  931. X#define STDOUT 1
  932. X#endif
  933. X
  934. X#define LBRACE '{'
  935. X#define RBRACE '}'
  936. X
  937. X#define APPEND_TOKEN {token[t_num].length++; current++;}
  938. X
  939. X#define SCAN_IDENTIFIER while (isident(expression[current + 1]))\
  940. X                APPEND_TOKEN
  941. X
  942. Xextern struct lexical_unit token[MAX_TOKENS];
  943. X
  944. Xstatic int t_num;    /* number of token I'm working on */
  945. X
  946. Xchar *strcat(), *strcpy(), *strncpy();
  947. X
  948. X/*
  949. X * scanner() breaks expression[] into lexical units, storing them in token[].
  950. X *   The total number of tokens found is returned as the function value.
  951. X *   Scanning will stop when '\0' is found in expression[], or when token[]
  952. X *     is full.
  953. X *
  954. X *     Scanning is performed by following rules:
  955. X *
  956. X *        Current char    token should contain
  957. X *     -------------    -----------------------
  958. X *        1.  alpha        all following alpha-numerics
  959. X *        2.  digit        0 or more following digits, 0 or 1 decimal point,
  960. X *                          0 or more digits, 0 or 1 'e' or 'E',
  961. X *                          0 or more digits.
  962. X *        3.  ^,+,-,/        only current char
  963. X *            %,~,(,)
  964. X *            [,],;,:,
  965. X *            ?,comma
  966. X *        4.  &,|,=,*        current char; also next if next is same
  967. X *        5.  !,<,>        current char; also next if next is =
  968. X *        6.  ", '        all chars up until matching quote
  969. X *
  970. X *        white space between tokens is ignored
  971. X */
  972. Xscanner(expression)
  973. Xchar expression[];
  974. X{
  975. Xregister int current;    /* index of current char in expression[] */
  976. Xregister int quote;
  977. Xchar brace;
  978. X
  979. X    for (current = t_num = 0;
  980. X        t_num < MAX_TOKENS && expression[current] != '\0';
  981. X        current++) {
  982. Xagain:
  983. X        if (isspace(expression[current]))
  984. X            continue;                        /* skip the whitespace */
  985. X        token[t_num].start_index = current;
  986. X        token[t_num].length = 1;
  987. X        token[t_num].is_token = TRUE;    /* to start with...*/
  988. X
  989. X        if (expression[current] == '`') {
  990. X            substitute(&expression[current],MAX_LINE_LEN - current);
  991. X            goto again;
  992. X        }
  993. X        if (isalpha(expression[current])) {
  994. X            SCAN_IDENTIFIER;
  995. X        } else if (isdigit(expression[current]) || expression[current] == '.'){
  996. X            token[t_num].is_token = FALSE;
  997. X            token[t_num].length = get_num(&expression[current]);
  998. X            current += (token[t_num].length - 1);
  999. X        } else if (expression[current] == LBRACE) {
  1000. X            token[t_num].is_token = FALSE;
  1001. X            token[t_num].l_val.type = CMPLX;
  1002. X            if ((sscanf(&expression[++current],"%lf , %lf %c",
  1003. X                &token[t_num].l_val.v.cmplx_val.real,
  1004. X                &token[t_num].l_val.v.cmplx_val.imag,
  1005. X                &brace) != 3) || (brace != RBRACE))
  1006. X                    int_error("invalid complex constant",t_num);
  1007. X            token[t_num].length += 2;
  1008. X            while (expression[++current] != RBRACE) {
  1009. X                token[t_num].length++;
  1010. X                if (expression[current] == '\0')            /* { for vi % */
  1011. X                    int_error("no matching '}'", t_num);
  1012. X            }
  1013. X        } else if (expression[current] == '\'' || expression[current] == '\"'){
  1014. X            token[t_num].length++;
  1015. X            quote = expression[current];
  1016. X            while (expression[++current] != quote) {
  1017. X                if (!expression[current]) {
  1018. X                    expression[current] = quote;
  1019. X                    expression[current+1] = '\0';
  1020. X                    break;
  1021. X                } else
  1022. X                    token[t_num].length++;
  1023. X            }
  1024. X        } else switch (expression[current]) {
  1025. X            case '^':
  1026. X            case '+':
  1027. X            case '-':
  1028. X            case '/':
  1029. X            case '%':
  1030. X            case '~':
  1031. X            case '(':
  1032. X            case ')':
  1033. X            case '[':
  1034. X            case ']':
  1035. X            case ';':
  1036. X            case ':':
  1037. X            case '?':
  1038. X            case ',':
  1039. X                break;
  1040. X            case '&':
  1041. X            case '|':
  1042. X            case '=':
  1043. X            case '*':
  1044. X                if (expression[current] == expression[current + 1])
  1045. X                    APPEND_TOKEN;
  1046. X                break;
  1047. X            case '!':
  1048. X            case '<':
  1049. X            case '>':
  1050. X                if (expression[current + 1] == '=')
  1051. X                    APPEND_TOKEN;
  1052. X                break;
  1053. X            default:
  1054. X                int_error("invalid character",t_num);
  1055. X            }
  1056. X        ++t_num;    /* next token if not white space */
  1057. X    }
  1058. X
  1059. X/* Now kludge an extra token which points to '\0' at end of expression[].
  1060. X   This is useful so printerror() looks nice even if we've fallen off the
  1061. X   line. */
  1062. X
  1063. X        token[t_num].start_index = current;
  1064. X        token[t_num].length = 0;
  1065. X    return(t_num);
  1066. X}
  1067. X
  1068. X
  1069. Xget_num(str)
  1070. Xchar str[];
  1071. X{
  1072. Xdouble atof();
  1073. Xregister int count = 0;
  1074. Xlong atol();
  1075. Xregister long lval;
  1076. X
  1077. X    token[t_num].is_token = FALSE;
  1078. X    token[t_num].l_val.type = INT;        /* assume unless . or E found */
  1079. X    while (isdigit(str[count]))
  1080. X        count++;
  1081. X    if (str[count] == '.') {
  1082. X        token[t_num].l_val.type = CMPLX;
  1083. X        while (isdigit(str[++count]))    /* swallow up digits until non-digit */
  1084. X            ;
  1085. X        /* now str[count] is other than a digit */
  1086. X    }
  1087. X    if (str[count] == 'e' || str[count] == 'E') {
  1088. X        token[t_num].l_val.type = CMPLX;
  1089. X        if (str[++count] == '-')
  1090. X            count++;
  1091. X        if (!isdigit(str[count])) {
  1092. X            token[t_num].start_index += count;
  1093. X            int_error("expecting exponent",t_num);
  1094. X        }
  1095. X        while (isdigit(str[++count]))
  1096. X            ;
  1097. X    }
  1098. X    if (token[t_num].l_val.type == INT) {
  1099. X         lval = atol(str);
  1100. X        if ((token[t_num].l_val.v.int_val = lval) != lval)
  1101. X            int_error("integer overflow; change to floating point",t_num);
  1102. X    } else {
  1103. X        token[t_num].l_val.v.cmplx_val.imag = 0.0;
  1104. X        token[t_num].l_val.v.cmplx_val.real = atof(str);
  1105. X    }
  1106. X    return(count);
  1107. X}
  1108. X
  1109. X
  1110. X#ifdef MSDOS
  1111. X
  1112. Xsubstitute()
  1113. X{
  1114. X    int_error("substitution not supported by MS-DOS!",t_num);
  1115. X}
  1116. X
  1117. X#else /* MSDOS */
  1118. X
  1119. Xsubstitute(str,max)            /* substitute output from ` ` */
  1120. Xchar *str;
  1121. Xint max;
  1122. X{
  1123. Xregister char *last;
  1124. Xregister int i,c;
  1125. Xregister FILE *f;
  1126. XFILE *popen();
  1127. Xstatic char pgm[MAX_LINE_LEN+1],output[MAX_LINE_LEN+1];
  1128. X
  1129. X#ifdef vms
  1130. Xint chan;
  1131. Xstatic $DESCRIPTOR(pgmdsc,pgm);
  1132. Xstatic $DESCRIPTOR(lognamedsc,MAILBOX);
  1133. X#endif /* vms */
  1134. X
  1135. X    i = 0;
  1136. X    last = str;
  1137. X    while (*(++last) != '`') {
  1138. X        if (*last == '\0')
  1139. X            int_error("unmatched `",t_num);
  1140. X        pgm[i++] = *last;
  1141. X    }
  1142. X    pgm[i] = '\0';        /* end with null */
  1143. X    max -= strlen(last);    /* max is now the max length of output sub. */
  1144. X  
  1145. X#ifdef vms
  1146. X      pgmdsc.dsc$w_length = i;
  1147. X       if (!((vaxc$errno = sys$crembx(0,&chan,0,0,0,0,&lognamedsc)) & 1))
  1148. X           os_error("sys$crembx failed",NO_CARET);
  1149. X   
  1150. X       if (!((vaxc$errno = lib$spawn(&pgmdsc,0,&lognamedsc,&1)) & 1))
  1151. X           os_error("lib$spawn failed",NO_CARET);
  1152. X   
  1153. X       if ((f = fopen(MAILBOX,"r")) == NULL)
  1154. X           os_error("mailbox open failed",NO_CARET);
  1155. X#else /* vms */
  1156. X      if ((f = popen(pgm,"r")) == NULL)
  1157. X          os_error("popen failed",NO_CARET);
  1158. X#endif /* vms */
  1159. X
  1160. X    i = 0;
  1161. X    while ((c = getc(f)) != EOF) {
  1162. X        output[i++] = ((c == '\n') ? ' ' : c);    /* newlines become blanks*/
  1163. X        if (i == max) {
  1164. X            (void) pclose(f);
  1165. X            int_error("substitution overflow", t_num);
  1166. X        }
  1167. X    }
  1168. X    (void) pclose(f);
  1169. X    if (i + strlen(last) > max)
  1170. X        int_error("substitution overflowed rest of line", t_num);
  1171. X    (void) strncpy(output+i,last+1,MAX_LINE_LEN-i);
  1172. X                                    /* tack on rest of line to output */
  1173. X    (void) strcpy(str,output);                /* now replace ` ` with output */
  1174. X    screen_ok = FALSE;
  1175. X}
  1176. X#endif /* MS-DOS */
  1177. END_OF_FILE
  1178. if test 7076 -ne `wc -c <'scanner.c'`; then
  1179.     echo shar: \"'scanner.c'\" unpacked with wrong size!
  1180. fi
  1181. # end of 'scanner.c'
  1182. fi
  1183. if test -f 'selanar.trm' -a "${1}" != "-c" ; then 
  1184.   echo shar: Will not clobber existing file \"'selanar.trm'\"
  1185. else
  1186. echo shar: Extracting \"'selanar.trm'\" \(666 characters\)
  1187. sed "s/^X//" >'selanar.trm' <<'END_OF_FILE'
  1188. X/* thanks to sask!macphed (Geoff Coleman and Ian Macphedran) for the
  1189. X   Selanar driver */
  1190. X
  1191. XSEL_init()
  1192. X{
  1193. X    fprintf(outfile,"\033\062");
  1194. X/*                    1
  1195. X    1. set to ansi mode
  1196. X*/
  1197. X}
  1198. X
  1199. X
  1200. XSEL_graphics()
  1201. X{
  1202. X    fprintf(outfile,"\033[H\033[J\033\061\033\014");
  1203. X/*                   1           2       3
  1204. X    1. clear ANSI screen
  1205. X    2. set to TEK mode
  1206. X    3. clear screen
  1207. X*/
  1208. X}
  1209. X
  1210. X
  1211. XSEL_text()
  1212. X{
  1213. X    TEK40move(0,12);
  1214. X    fprintf(outfile,"\033\062");
  1215. X/*                   1
  1216. X    1. into ANSI mode
  1217. X*/
  1218. X}
  1219. X
  1220. XSEL_reset()
  1221. X{
  1222. X    fprintf(outfile,"\033\061\033\012\033\062\033[H\033[J");
  1223. X/*                   1        2       3      4
  1224. X1       set tek mode
  1225. X2       clear screen
  1226. X3       set ansi mode
  1227. X4       clear screen
  1228. X*/
  1229. X}
  1230. X
  1231. END_OF_FILE
  1232. if test 666 -ne `wc -c <'selanar.trm'`; then
  1233.     echo shar: \"'selanar.trm'\" unpacked with wrong size!
  1234. fi
  1235. # end of 'selanar.trm'
  1236. fi
  1237. if test ! -d 'shar' ; then
  1238.     echo shar: Creating directory \"'shar'\"
  1239.     mkdir 'shar'
  1240. fi
  1241. if test -f 'simple.dem' -a "${1}" != "-c" ; then 
  1242.   echo shar: Will not clobber existing file \"'simple.dem'\"
  1243. else
  1244. echo shar: Extracting \"'simple.dem'\" \(551 characters\)
  1245. sed "s/^X//" >'simple.dem' <<'END_OF_FILE'
  1246. X#
  1247. X# gnuplot> set term <term-type>
  1248. X# gnuplot> load 'simple.dem'
  1249. X#
  1250. Xset samples 50
  1251. Xplot [-10:10] sin(x),atan(x),cos(atan(x))
  1252. Xset samples 100
  1253. Xplot [-pi/2:pi] cos(x),-(sin(x) > sin(x+1) ? sin(x) : sin(x+1))
  1254. Xset samples 200
  1255. Xplot [-3:5] asin(x),acos(x)
  1256. Xplot [-30:20] besj0(x)*0.12e1 with impulses, (x**besj0(x))-2.5 with points
  1257. Xset samples 400
  1258. Xplot [-10:10] real(sin(x)**besj0(x))
  1259. Xplot [-5*pi:5*pi] [-5:5] real(tan(x)/atan(x)), 1/x
  1260. Xset autoscale
  1261. Xset samples 800
  1262. Xplot [-30:20] sin(x*20)*atan(x)
  1263. Xplot [-19:19] '1.dat'with impulses ,'2.dat' ,'3.dat' with lines
  1264. END_OF_FILE
  1265. if test 551 -ne `wc -c <'simple.dem'`; then
  1266.     echo shar: \"'simple.dem'\" unpacked with wrong size!
  1267. fi
  1268. # end of 'simple.dem'
  1269. fi
  1270. if test -f 'standard.c' -a "${1}" != "-c" ; then 
  1271.   echo shar: Will not clobber existing file \"'standard.c'\"
  1272. else
  1273. echo shar: Extracting \"'standard.c'\" \(5952 characters\)
  1274. sed "s/^X//" >'standard.c' <<'END_OF_FILE'
  1275. X/*
  1276. X *
  1277. X *    G N U P L O T  --  standard.c
  1278. X *
  1279. X *  Copyright (C) 1986, 1987  Thomas Williams, Colin Kelley
  1280. X *
  1281. X *  You may use this code as you wish if credit is given and this message
  1282. X *  is retained.
  1283. X *
  1284. X *  Please e-mail any useful additions to vu-vlsi!plot so they may be
  1285. X *  included in later releases.
  1286. X *
  1287. X *  This file should be edited with 4-column tabs!  (:set ts=4 sw=4 in vi)
  1288. X */
  1289. X
  1290. X#include <math.h>
  1291. X#include <stdio.h>
  1292. X#include "plot.h"
  1293. X
  1294. Xextern BOOLEAN undefined;
  1295. X
  1296. X#ifdef vms
  1297. X#include <errno.h>
  1298. X#else
  1299. Xextern int errno;
  1300. X#endif /* vms */
  1301. X
  1302. X
  1303. Xextern struct value stack[STACK_DEPTH];
  1304. Xextern int s_p;
  1305. X
  1306. Xstruct value *pop(), *complex(), *integer();
  1307. X
  1308. Xdouble magnitude(), angle(), real(), imag();
  1309. X
  1310. X
  1311. Xf_real()
  1312. X{
  1313. Xstruct value a;
  1314. X    push( complex(&a,real(pop(&a)), 0.0) );
  1315. X}
  1316. X
  1317. Xf_imag()
  1318. X{
  1319. Xstruct value a;
  1320. X    push( complex(&a,imag(pop(&a)), 0.0) );
  1321. X}
  1322. X
  1323. Xf_arg()
  1324. X{
  1325. Xstruct value a;
  1326. X    push( complex(&a,angle(pop(&a)), 0.0) );
  1327. X}
  1328. X
  1329. Xf_conjg()
  1330. X{
  1331. Xstruct value a;
  1332. X    (void) pop(&a);
  1333. X    push( complex(&a,real(&a),-imag(&a) ));
  1334. X}
  1335. X
  1336. Xf_sin()
  1337. X{
  1338. Xstruct value a;
  1339. X    (void) pop(&a);
  1340. X    push( complex(&a,sin(real(&a))*cosh(imag(&a)), cos(real(&a))*sinh(imag(&a))) );
  1341. X}
  1342. X
  1343. Xf_cos()
  1344. X{
  1345. Xstruct value a;
  1346. X    (void) pop(&a);
  1347. X    push( complex(&a,cos(real(&a))*cosh(imag(&a)), -sin(real(&a))*sinh(imag(&a))));
  1348. X}
  1349. X
  1350. Xf_tan()
  1351. X{
  1352. Xstruct value a;
  1353. Xregister double den;
  1354. X    (void) pop(&a);
  1355. X    if (imag(&a) == 0.0)
  1356. X        push( complex(&a,tan(real(&a)),0.0) );
  1357. X    else {
  1358. X        den = cos(2*real(&a))+cosh(2*imag(&a));
  1359. X        if (den == 0.0) {
  1360. X            undefined = TRUE;
  1361. X            push( &a );
  1362. X        }
  1363. X        else
  1364. X            push( complex(&a,sin(2*real(&a))/den, sinh(2*imag(&a))/den) );
  1365. X    }
  1366. X}
  1367. X
  1368. Xf_asin()
  1369. X{
  1370. Xstruct value a;
  1371. Xregister double alpha, beta, x, y;
  1372. X    (void) pop(&a);
  1373. X    x = real(&a); y = imag(&a);
  1374. X    if (y == 0.0) {
  1375. X        if (fabs(x) > 1.0) {
  1376. X            undefined = TRUE;
  1377. X            push(complex(&a,0.0, 0.0));
  1378. X        } else
  1379. X            push( complex(&a,asin(x),0.0) );
  1380. X    } else {
  1381. X        beta  = sqrt((x + 1)*(x + 1) + y*y)/2 - sqrt((x - 1)*(x - 1) + y*y)/2;
  1382. X        alpha = sqrt((x + 1)*(x + 1) + y*y)/2 + sqrt((x - 1)*(x - 1) + y*y)/2;
  1383. X        push( complex(&a,asin(beta), log(alpha + sqrt(alpha*alpha-1))) );
  1384. X    }
  1385. X}
  1386. X
  1387. Xf_acos()
  1388. X{
  1389. Xstruct value a;
  1390. Xregister double alpha, beta, x, y;
  1391. X    (void) pop(&a);
  1392. X    x = real(&a); y = imag(&a);
  1393. X    if (y == 0.0) {
  1394. X        if (fabs(x) > 1.0) {
  1395. X            undefined = TRUE;
  1396. X            push(complex(&a,0.0, 0.0));
  1397. X        } else
  1398. X            push( complex(&a,acos(x),0.0) );
  1399. X    } else {
  1400. X        alpha = sqrt((x + 1)*(x + 1) + y*y)/2 + sqrt((x - 1)*(x - 1) + y*y)/2;
  1401. X        beta  = sqrt((x + 1)*(x + 1) + y*y)/2 - sqrt((x - 1)*(x - 1) + y*y)/2;
  1402. X        push( complex(&a,acos(beta), log(alpha + sqrt(alpha*alpha-1))) );
  1403. X    }
  1404. X}
  1405. X
  1406. Xf_atan()
  1407. X{
  1408. Xstruct value a;
  1409. Xregister double x, y;
  1410. X    (void) pop(&a);
  1411. X    x = real(&a); y = imag(&a);
  1412. X    if (y == 0.0)
  1413. X        push( complex(&a,atan(x), 0.0) );
  1414. X    else if (x == 0.0 && fabs(y) == 1.0) {
  1415. X        undefined = TRUE;
  1416. X        push(complex(&a,0.0, 0.0));
  1417. X    } else
  1418. X        push( complex(&a,atan(2*x/(1-x*x-y*y)),
  1419. X                log((x*x+(y+1)*(y+1))/(x*x+(y-1)*(y-1)))/4) );
  1420. X}
  1421. X
  1422. Xf_sinh()
  1423. X{
  1424. Xstruct value a;
  1425. X    (void) pop(&a);
  1426. X    push( complex(&a,sinh(real(&a))*cos(imag(&a)), cosh(real(&a))*sin(imag(&a))) );
  1427. X}
  1428. X
  1429. Xf_cosh()
  1430. X{
  1431. Xstruct value a;
  1432. X    (void) pop(&a);
  1433. X    push( complex(&a,cosh(real(&a))*cos(imag(&a)), sinh(real(&a))*sin(imag(&a))) );
  1434. X}
  1435. X
  1436. Xf_tanh()
  1437. X{
  1438. Xstruct value a;
  1439. Xregister double den;
  1440. X    (void) pop(&a);
  1441. X    den = cosh(2*real(&a)) + cos(2*imag(&a));
  1442. X    push( complex(&a,sinh(2*real(&a))/den, sin(2*imag(&a))/den) );
  1443. X}
  1444. X
  1445. Xf_int()
  1446. X{
  1447. Xstruct value a;
  1448. X    push( integer(&a,(int)real(pop(&a))) );
  1449. X}
  1450. X
  1451. X
  1452. Xf_abs()
  1453. X{
  1454. Xstruct value a;
  1455. X    (void) pop(&a);
  1456. X    switch (a.type) {
  1457. X        case INT:
  1458. X            push( integer(&a,abs(a.v.int_val)) );            
  1459. X            break;
  1460. X        case CMPLX:
  1461. X            push( complex(&a,magnitude(&a), 0.0) );
  1462. X    }
  1463. X}
  1464. X
  1465. Xf_sgn()
  1466. X{
  1467. Xstruct value a;
  1468. X    (void) pop(&a);
  1469. X    switch(a.type) {
  1470. X        case INT:
  1471. X            push( integer(&a,(a.v.int_val > 0) ? 1 : 
  1472. X                    (a.v.int_val < 0) ? -1 : 0) );
  1473. X            break;
  1474. X        case CMPLX:
  1475. X            push( integer(&a,(a.v.cmplx_val.real > 0.0) ? 1 : 
  1476. X                    (a.v.cmplx_val.real < 0.0) ? -1 : 0) );
  1477. X            break;
  1478. X    }
  1479. X}
  1480. X
  1481. X
  1482. Xf_sqrt()
  1483. X{
  1484. Xstruct value a;
  1485. Xregister double mag, ang;
  1486. X    (void) pop(&a);
  1487. X    mag = sqrt(magnitude(&a));
  1488. X    if (imag(&a) == 0.0 && real(&a) < 0.0)
  1489. X        push( complex(&a,0.0,mag) );
  1490. X    else
  1491. X    {
  1492. X        if ( (ang = angle(&a)) < 0.0)
  1493. X            ang += 2*Pi;
  1494. X        ang /= 2;
  1495. X        push( complex(&a,mag*cos(ang), mag*sin(ang)) );
  1496. X    }
  1497. X}
  1498. X
  1499. X
  1500. Xf_exp()
  1501. X{
  1502. Xstruct value a;
  1503. Xregister double mag, ang;
  1504. X    (void) pop(&a);
  1505. X    mag = exp(real(&a));
  1506. X    ang = imag(&a);
  1507. X    push( complex(&a,mag*cos(ang), mag*sin(ang)) );
  1508. X}
  1509. X
  1510. X
  1511. Xf_log10()
  1512. X{
  1513. Xstruct value a;
  1514. Xregister double l10;;
  1515. X    (void) pop(&a);
  1516. X    l10 = log(10.0);    /***** replace with a constant! ******/
  1517. X    push( complex(&a,log(magnitude(&a))/l10, angle(&a)/l10) );
  1518. X}
  1519. X
  1520. X
  1521. Xf_log()
  1522. X{
  1523. Xstruct value a;
  1524. X    (void) pop(&a);
  1525. X    push( complex(&a,log(magnitude(&a)), angle(&a)) );
  1526. X}
  1527. X
  1528. X
  1529. Xf_besj0()    /* j0(a) = sin(a)/a */
  1530. X{
  1531. Xstruct value a;
  1532. X    a = top_of_stack;
  1533. X    f_sin();
  1534. X    push(&a);
  1535. X    f_div();
  1536. X}
  1537. X
  1538. X
  1539. Xf_besj1()    /* j1(a) = sin(a)/(a**2) - cos(a)/a */
  1540. X{
  1541. Xstruct value a;
  1542. X    a = top_of_stack;
  1543. X    f_sin();
  1544. X    push(&a);
  1545. X    push(&a);
  1546. X    f_mult();
  1547. X    f_div();
  1548. X    push(&a);
  1549. X    f_cos();
  1550. X    push(&a);
  1551. X    f_div();
  1552. X    f_minus();
  1553. X}
  1554. X
  1555. X
  1556. Xf_besy0()    /* y0(a) = -cos(a)/a */
  1557. X{
  1558. Xstruct value a;
  1559. X    a = top_of_stack;
  1560. X    f_cos();
  1561. X    push(&a);
  1562. X    f_div();
  1563. X    f_uminus();
  1564. X}
  1565. X
  1566. X
  1567. Xf_besy1()    /* y1(a) = -cos(a)/(a**2) - sin(a)/a */
  1568. X{
  1569. Xstruct value a;
  1570. X
  1571. X    a = top_of_stack;
  1572. X    f_cos();
  1573. X    push(&a);
  1574. X    push(&a);
  1575. X    f_mult();
  1576. X    f_div();
  1577. X    push(&a);
  1578. X    f_sin();
  1579. X    push(&a);
  1580. X    f_div();
  1581. X    f_plus();
  1582. X    f_uminus();
  1583. X}
  1584. X
  1585. X
  1586. Xf_floor()
  1587. X{
  1588. Xstruct value a;
  1589. X
  1590. X    (void) pop(&a);
  1591. X    switch (a.type) {
  1592. X        case INT:
  1593. X            push( integer(&a,(int)floor((double)a.v.int_val)));            
  1594. X            break;
  1595. X        case CMPLX:
  1596. X            push( complex(&a,floor(a.v.cmplx_val.real),
  1597. X                floor(a.v.cmplx_val.imag)) );
  1598. X    }
  1599. X}
  1600. X
  1601. X
  1602. Xf_ceil()
  1603. X{
  1604. Xstruct value a;
  1605. X
  1606. X    (void) pop(&a);
  1607. X    switch (a.type) {
  1608. X        case INT:
  1609. X            push( integer(&a,(int)ceil((double)a.v.int_val)));            
  1610. X            break;
  1611. X        case CMPLX:
  1612. X            push( complex(&a,ceil(a.v.cmplx_val.real), ceil(a.v.cmplx_val.imag)) );
  1613. X    }
  1614. X}
  1615. X
  1616. X#ifdef GAMMA
  1617. X
  1618. Xf_gamma()
  1619. X{
  1620. Xextern int signgam;
  1621. Xregister double y;
  1622. Xstruct value a;
  1623. X
  1624. X    y = gamma(real(pop(&a)));
  1625. X    if (y > 88.0) {
  1626. X        undefined = TRUE;
  1627. X        push( integer(&a,0) );
  1628. X    }
  1629. X    else
  1630. X        push( complex(&a,signgam * exp(y),0.0) );
  1631. X}
  1632. X
  1633. X#endif /* GAMMA */
  1634. END_OF_FILE
  1635. if test 5952 -ne `wc -c <'standard.c'`; then
  1636.     echo shar: \"'standard.c'\" unpacked with wrong size!
  1637. fi
  1638. # end of 'standard.c'
  1639. fi
  1640. if test -f 'tek.trm' -a "${1}" != "-c" ; then 
  1641.   echo shar: Will not clobber existing file \"'tek.trm'\"
  1642. else
  1643. echo shar: Extracting \"'tek.trm'\" \(1332 characters\)
  1644. sed "s/^X//" >'tek.trm' <<'END_OF_FILE'
  1645. X#define TEK40XMAX 1024
  1646. X#define TEK40YMAX 780
  1647. X
  1648. X#define TEK40XLAST (TEK40XMAX - 1)
  1649. X#define TEK40YLAST (TEK40YMAX - 1)
  1650. X
  1651. X#define TEK40VCHAR        25
  1652. X#define TEK40HCHAR        14
  1653. X#define TEK40VTIC        11
  1654. X#define TEK40HTIC        11    
  1655. X
  1656. X#define HX 0x20        /* bit pattern to OR over 5-bit data */
  1657. X#define HY 0x20
  1658. X#define LX 0x40
  1659. X#define LY 0x60
  1660. X
  1661. X#define LOWER5 31
  1662. X#define UPPER5 (31<<5)
  1663. X
  1664. X
  1665. XTEK40init()
  1666. X{
  1667. X}
  1668. X
  1669. X
  1670. XTEK40graphics()
  1671. X{
  1672. X    fprintf(outfile,"\033\014");
  1673. X/*                   1
  1674. X    1. clear screen
  1675. X*/
  1676. X}
  1677. X
  1678. X
  1679. XTEK40text()
  1680. X{
  1681. X    TEK40move(0,12);
  1682. X    fprintf(outfile,"\037");
  1683. X/*                   1
  1684. X    1. into alphanumerics
  1685. X*/
  1686. X}
  1687. X
  1688. X
  1689. XTEK40linetype(linetype)
  1690. Xint linetype;
  1691. X{
  1692. X}
  1693. X
  1694. X
  1695. XTEK40move(x,y)
  1696. Xunsigned int x,y;
  1697. X{
  1698. X    (void) putc('\035', outfile);    /* into graphics */
  1699. X    TEK40vector(x,y);
  1700. X}
  1701. X
  1702. X
  1703. XTEK40vector(x,y)
  1704. Xunsigned int x,y;
  1705. X{
  1706. X    (void) putc((HY | (y & UPPER5)>>5), outfile);
  1707. X    (void) putc((LY | (y & LOWER5)), outfile);
  1708. X    (void) putc((HX | (x & UPPER5)>>5), outfile);
  1709. X    (void) putc((LX | (x & LOWER5)), outfile);
  1710. X}
  1711. X
  1712. X
  1713. XTEK40lrput_text(row,str)
  1714. Xunsigned int row;
  1715. Xchar str[];
  1716. X{
  1717. X    TEK40move(TEK40XMAX - TEK40HTIC - TEK40HCHAR*(strlen(str)+1),
  1718. X        TEK40VTIC + TEK40VCHAR*(row+1));
  1719. X    fprintf(outfile,"\037%s\n",str);
  1720. X}
  1721. X
  1722. X
  1723. XTEK40ulput_text(row,str)
  1724. Xunsigned int row;
  1725. Xchar str[];
  1726. X{
  1727. X    TEK40move(TEK40HTIC, TEK40YMAX - TEK40VTIC - TEK40VCHAR*(row+1));
  1728. X    fprintf(outfile,"\037%s\n",str);
  1729. X}
  1730. X
  1731. X
  1732. XTEK40reset()
  1733. X{
  1734. X}
  1735. X
  1736. X
  1737. END_OF_FILE
  1738. if test 1332 -ne `wc -c <'tek.trm'`; then
  1739.     echo shar: \"'tek.trm'\" unpacked with wrong size!
  1740. fi
  1741. # end of 'tek.trm'
  1742. fi
  1743. if test -f 'term.c' -a "${1}" != "-c" ; then 
  1744.   echo shar: Will not clobber existing file \"'term.c'\"
  1745. else
  1746. echo shar: Extracting \"'term.c'\" \(19496 characters\)
  1747. sed "s/^X//" >'term.c' <<'END_OF_FILE'
  1748. X/*
  1749. X *
  1750. X *    G N U P L O T  --  term.c
  1751. X *
  1752. X *  Copyright (C) 1986, 1987  Colin Kelley, Thomas Williams
  1753. X *
  1754. X *  You may use this code as you wish if credit is given and this message
  1755. X *  is retained.
  1756. X *
  1757. X *  Please e-mail any useful additions to vu-vlsi!plot so they may be
  1758. X *  included in later releases.
  1759. X *
  1760. X *  This file should be edited with 4-column tabs!  (:set ts=4 sw=4 in vi)
  1761. X */
  1762. X
  1763. X#include <stdio.h>
  1764. X#include "plot.h"
  1765. X
  1766. Xchar *getenv();
  1767. X
  1768. Xextern FILE *outfile;
  1769. Xextern BOOLEAN term_init;
  1770. Xextern int term;
  1771. X
  1772. Xextern char input_line[];
  1773. Xextern struct lexical_unit token[];
  1774. Xextern struct termentry term_tbl[];
  1775. X
  1776. X/* This is needed because the unixplot library only writes to stdout. */
  1777. XFILE save_stdout;
  1778. Xint unixplot=0;
  1779. X
  1780. X#define NICE_LINE        0
  1781. X#define POINT_TYPES        6
  1782. X
  1783. X
  1784. Xdo_point(x,y,number)
  1785. Xint x,y;
  1786. Xint number;
  1787. X{
  1788. Xregister int htic,vtic;
  1789. Xregister struct termentry *t;
  1790. X
  1791. X    number %= POINT_TYPES;
  1792. X    t = &term_tbl[term];
  1793. X    htic = (t->h_tic/2);    /* should be in term_tbl[] in later version */
  1794. X    vtic = (t->v_tic/2);    
  1795. X
  1796. X    if ( x < t->h_tic || y < t->v_tic || x >= t->xmax-t->h_tic ||
  1797. X        y >= t->ymax-t->v_tic ) 
  1798. X        return;                /* add clipping in later version maybe */
  1799. X
  1800. X    switch(number) {
  1801. X        case 0: /* do diamond */ 
  1802. X                (*t->move)(x-htic,y);
  1803. X                (*t->vector)(x,y-vtic);
  1804. X                (*t->vector)(x+htic,y);
  1805. X                (*t->vector)(x,y+vtic);
  1806. X                (*t->vector)(x-htic,y);
  1807. X                (*t->move)(x,y);
  1808. X                (*t->vector)(x,y);
  1809. X                break;
  1810. X        case 1: /* do plus */ 
  1811. X                (*t->move)(x-htic,y);
  1812. X                (*t->vector)(x-htic,y);
  1813. X                (*t->vector)(x+htic,y);
  1814. X                (*t->move)(x,y-vtic);
  1815. X                (*t->vector)(x,y-vtic);
  1816. X                (*t->vector)(x,y+vtic);
  1817. X                break;
  1818. X        case 2: /* do box */ 
  1819. X                (*t->move)(x-htic,y-vtic);
  1820. X                (*t->vector)(x+htic,y-vtic);
  1821. X                (*t->vector)(x+htic,y+vtic);
  1822. X                (*t->vector)(x-htic,y+vtic);
  1823. X                (*t->vector)(x-htic,y-vtic);
  1824. X                (*t->move)(x,y);
  1825. X                (*t->vector)(x,y);
  1826. X                break;
  1827. X        case 3: /* do X */ 
  1828. X                (*t->move)(x-htic,y-vtic);
  1829. X                (*t->vector)(x-htic,y-vtic);
  1830. X                (*t->vector)(x+htic,y+vtic);
  1831. X                (*t->move)(x-htic,y+vtic);
  1832. X                (*t->vector)(x-htic,y+vtic);
  1833. X                (*t->vector)(x+htic,y-vtic);
  1834. X                break;
  1835. X        case 4: /* do triangle */ 
  1836. X                (*t->move)(x,y+(4*vtic/3));
  1837. X                (*t->vector)(x-(4*htic/3),y-(2*vtic/3));
  1838. X                (*t->vector)(x+(4*htic/3),y-(2*vtic/3));
  1839. X                (*t->vector)(x,y+(4*vtic/3));
  1840. X                (*t->move)(x,y);
  1841. X                (*t->vector)(x,y);
  1842. X                break;
  1843. X        case 5: /* do star */ 
  1844. X                (*t->move)(x-htic,y);
  1845. X                (*t->vector)(x-htic,y);
  1846. X                (*t->vector)(x+htic,y);
  1847. X                (*t->move)(x,y-vtic);
  1848. X                (*t->vector)(x,y-vtic);
  1849. X                (*t->vector)(x,y+vtic);
  1850. X                (*t->move)(x-htic,y-vtic);
  1851. X                (*t->vector)(x-htic,y-vtic);
  1852. X                (*t->vector)(x+htic,y+vtic);
  1853. X                (*t->move)(x-htic,y+vtic);
  1854. X                (*t->vector)(x-htic,y+vtic);
  1855. X                (*t->vector)(x+htic,y-vtic);
  1856. X                break;
  1857. X    }
  1858. X}
  1859. X
  1860. X
  1861. X/*
  1862. X * general point routine
  1863. X */
  1864. Xline_and_point(x,y,number)
  1865. Xint x,y,number;
  1866. X{
  1867. X    /* temporary(?) kludge to allow terminals with bad linetypes 
  1868. X        to make nice marks */
  1869. X
  1870. X    (*term_tbl[term].linetype)(NICE_LINE);
  1871. X    do_point(x,y,number);
  1872. X}
  1873. X
  1874. X
  1875. X#ifdef HPLJET
  1876. X#define RASTER
  1877. X#endif /* HPLJET */
  1878. X
  1879. X#ifdef RASTER
  1880. X/*
  1881. X** General raster plotting routines.
  1882. X** Raster routines written and copyrighted 1987 by
  1883. X** Jyrki Yli-Nokari (jty@intrin.UUCP)
  1884. X** Intrinsic, Ltd.
  1885. X** 
  1886. X** You may use this code for anything you like as long as
  1887. X** you are not selling it and the credit is given and
  1888. X** this message retained.
  1889. X**
  1890. X** The plotting area is defined as a huge raster.
  1891. X** The raster is stored in a dynamically allocated pixel array r_p
  1892. X**
  1893. X** The raster is allocated (and initialized to zero) with
  1894. X** r_makeraster(xsize, ysize)
  1895. X** and freed with r_freeraster()
  1896. X**
  1897. X** Valid (unsigned) coordinates range from zero to (xsize-1,ysize-1)
  1898. X**
  1899. X** Plotting is done via r_move(x, y) and r_draw(x, y, value) functions,
  1900. X** where the point (x,y) is the target to go from the current point
  1901. X** and value is the value (of type pixel) to be stored in every pixel.
  1902. X**
  1903. X** Internally all plotting goes through r_setpixel(x, y, val).
  1904. X** If you want different plotting styles (like OR, XOR...), use "value"
  1905. X** in r_draw() to mark different styles and change r_setpixel() accordingly.
  1906. X*/
  1907. X
  1908. X#define IN(i,size)    ((unsigned)i < (unsigned)size)
  1909. Xtypedef char pixel;    /* the type of one pixel in raster */
  1910. Xtypedef pixel *raster[];    /* the raster */
  1911. X
  1912. Xstatic raster *r_p;    /* global pointer to raster */
  1913. Xstatic unsigned r_currx, r_curry;    /* the current coordinates */
  1914. Xstatic unsigned r_xsize, r_ysize;    /* the size of the raster */
  1915. X
  1916. Xchar *calloc();
  1917. Xvoid free();
  1918. X
  1919. X/*
  1920. X** set pixel (x, y, val) to value val (this can be 1/0 or a color number).
  1921. X*/
  1922. Xvoid
  1923. Xr_setpixel(x, y, val)
  1924. Xunsigned x, y;
  1925. Xpixel val;
  1926. X{
  1927. X    if (IN(x, r_xsize) && IN(y, r_ysize)) {
  1928. X        *(((*r_p)[y]) + x) = val;
  1929. X    }
  1930. X#ifdef RASTERDEBUG
  1931. X    else {
  1932. X        fprintf(stderr, "Warning: setpixel(%d, %d, %d) out of bounds\n", x, y, val);
  1933. X    }
  1934. X#endif
  1935. X}
  1936. X
  1937. X/*
  1938. X** get pixel (x,y) value
  1939. X*/
  1940. Xpixel
  1941. Xr_getpixel(x, y)
  1942. Xunsigned x, y;
  1943. X{
  1944. X    if (IN(x, r_xsize) && IN(y, r_ysize)) {
  1945. X        return *(((*r_p)[y]) + x);
  1946. X    } else {
  1947. X#ifdef RASTERDEBUG
  1948. X        fprintf(stderr, "Warning: getpixel(%d,%d) out of bounds\n", x, y);
  1949. X#endif
  1950. X        return 0;
  1951. X    }
  1952. X}
  1953. X
  1954. X/*
  1955. X** allocate the raster
  1956. X*/
  1957. Xvoid
  1958. Xr_makeraster(x, y)
  1959. Xunsigned x, y;
  1960. X{
  1961. X    register unsigned j;
  1962. X    
  1963. X    /* allocate row pointers */
  1964. X    if ((r_p = (raster *)calloc(y, sizeof(pixel *))) == (raster *)0) {
  1965. X        fprintf(stderr, "Raster buffer allocation failure\n");
  1966. X        exit(1);
  1967. X    }
  1968. X    for (j = 0; j < y; j++) {
  1969. X        if (((*r_p)[j] = (pixel *)calloc(x, sizeof(pixel))) == (pixel *)0) {
  1970. X            fprintf(stderr, "Raster buffer allocation failure\n");
  1971. X            exit(1);
  1972. X        }
  1973. X    }
  1974. X    r_xsize = x; r_ysize = y;
  1975. X    r_currx = r_curry = 0;
  1976. X}
  1977. X    
  1978. X/*
  1979. X** plot a line from (x0,y0) to (x1,y1) with color val.
  1980. X*/
  1981. Xvoid
  1982. Xr_plot(x0, y0, x1, y1, val)
  1983. Xunsigned x0, y0, x1, y1;
  1984. Xpixel val;
  1985. X{
  1986. X    unsigned hx, hy, i;
  1987. X    int e, dx, dy;
  1988. X
  1989. X    hx = abs((int)(x1 - x0));
  1990. X    hy = abs((int)(y1 - y0));
  1991. X    dx = (x1 > x0) ? 1 : -1;
  1992. X    dy = (y1 > y0) ? 1 : -1;
  1993. X    
  1994. X    if (hx > hy) {
  1995. X        /*
  1996. X        ** loop over x-axis
  1997. X        */
  1998. X        e = hy + hy - hx;
  1999. X        for (i = 0; i <= hx; i++) {
  2000. X            r_setpixel(x0, y0, val);
  2001. X            if (e > 0) {
  2002. X                y0 += dy;
  2003. X                e += hy + hy - hx - hx;
  2004. X            } else {
  2005. X                e += hy + hy;
  2006. X            }
  2007. X            x0 += dx;
  2008. X        }
  2009. X    } else {
  2010. X        /*
  2011. X        ** loop over y-axis
  2012. X        */
  2013. X        e = hx + hx - hy;
  2014. X        for (i = 0; i <= hy; i++) {
  2015. X            r_setpixel(x0, y0, val);
  2016. X            if (e > 0) {
  2017. X                x0 += dx;
  2018. X                e += hx + hx - hy - hy;
  2019. X            } else {
  2020. X                e += hx + hx;
  2021. X            }
  2022. X            y0 += dy;
  2023. X        }
  2024. X    }
  2025. X}
  2026. X
  2027. X/*
  2028. X** move to (x,y)
  2029. X*/
  2030. Xvoid
  2031. Xr_move(x, y)
  2032. Xunsigned x, y;
  2033. X{
  2034. X    r_currx = x;
  2035. X    r_curry = y;
  2036. X}
  2037. X
  2038. X/*
  2039. X** draw to (x,y) with color val
  2040. X** (move pen down)
  2041. X*/
  2042. Xvoid
  2043. Xr_draw(x, y, val)
  2044. Xunsigned x, y;
  2045. Xpixel val;
  2046. X{
  2047. X    r_plot(r_currx, r_curry, x, y, val);
  2048. X    r_currx = x;
  2049. X    r_curry = y;
  2050. X}
  2051. X
  2052. X/*
  2053. X** free the allocated raster
  2054. X*/
  2055. Xvoid
  2056. Xr_freeraster()
  2057. X{
  2058. X    int y;
  2059. X
  2060. X    for (y = 0; y < r_ysize; y++) {
  2061. X        free((char *)(*r_p)[y]);
  2062. X    }
  2063. X    free((char *)r_p);
  2064. X}
  2065. X#endif /* RASTER */
  2066. X
  2067. X#ifdef HPLJET
  2068. X#include "hpljet.trm"
  2069. X#endif /* HPLJET */
  2070. X
  2071. X#ifdef PC
  2072. X#include "pc.trm"
  2073. X#endif /* PC */
  2074. X
  2075. X#ifdef AED
  2076. X#include "aed.trm"
  2077. X#endif /* AED */
  2078. X
  2079. X#ifdef BITGRAPH
  2080. X#include "bitgraph.trm"
  2081. X#endif /* BITGRAPH */
  2082. X
  2083. X#ifdef HP26
  2084. X#include "hp26.trm"
  2085. X#endif /* HP26 */
  2086. X
  2087. X#ifdef HP75
  2088. X#include "hp75.trm"
  2089. X#endif /* HP75 */
  2090. X
  2091. X#ifdef IRIS4D
  2092. X#include "iris4d.trm"
  2093. X#endif /* IRIS4D */
  2094. X#ifdef POSTSCRIPT
  2095. X#include "postscpt.trm"
  2096. X#endif /* POSTSCRIPT */
  2097. X
  2098. X
  2099. X#ifdef QMS
  2100. X#include "qms.trm"
  2101. X#endif /* QMS */
  2102. X
  2103. X
  2104. X#ifdef REGIS
  2105. X#include "regis.trm"
  2106. X#endif /* REGIS */
  2107. X
  2108. X
  2109. X#ifdef SELANAR
  2110. X#include "selanar.trm"
  2111. X#endif /* SELANAR */
  2112. X
  2113. X
  2114. X#ifdef TEK
  2115. X#include "tek.trm"
  2116. X#endif /* TEK */
  2117. X
  2118. X
  2119. X#ifdef V384
  2120. X#include "v384.trm"
  2121. X#endif /* V384 */
  2122. X
  2123. X
  2124. X#ifdef UNIXPLOT
  2125. X/*
  2126. X   Unixplot library writes to stdout.  A fix was put in place by
  2127. X   ..!arizona!naucse!jdc to let set term and set output redirect
  2128. X   stdout.  All other terminals write to outfile.
  2129. X*/
  2130. X#include "unixplot.trm"
  2131. X#endif /* UNIXPLOT */
  2132. X
  2133. X#ifdef UNIXPC     /* unix-PC  ATT 7300 or 3b1 machine */
  2134. X#include "unixpc.trm"
  2135. X#endif /* UNIXPC */
  2136. X
  2137. X
  2138. XUNKNOWN_null()
  2139. X{
  2140. X}
  2141. X
  2142. X
  2143. X/*
  2144. X * term_tbl[] contains an entry for each terminal.  "unknown" must be the
  2145. X *   first, since term is initialized to 0.
  2146. X */
  2147. Xstruct termentry term_tbl[] = {
  2148. X    {"unknown", 100, 100, 1, 1, 1, 1, UNKNOWN_null, UNKNOWN_null, UNKNOWN_null,
  2149. X    UNKNOWN_null, UNKNOWN_null, UNKNOWN_null, UNKNOWN_null, UNKNOWN_null,
  2150. X    UNKNOWN_null, UNKNOWN_null}
  2151. X#ifdef HPLJET
  2152. X    ,{"laserjet1",HPLJETXMAX,HPLJETYMAX,HPLJET1VCHAR, HPLJET1HCHAR, HPLJETVTIC,
  2153. X        HPLJETHTIC, HPLJET1init,HPLJETreset, HPLJETtext, HPLJETgraphics, 
  2154. X        HPLJETmove, HPLJETvector,HPLJETlinetype,HPLJETlrput_text,
  2155. X        HPLJETulput_text, line_and_point}
  2156. X    ,{"laserjet2",HPLJETXMAX,HPLJETYMAX,HPLJET2VCHAR, HPLJET2HCHAR, HPLJETVTIC, 
  2157. X        HPLJETHTIC, HPLJET2init,HPLJETreset, HPLJETtext, HPLJETgraphics, 
  2158. X        HPLJETmove, HPLJETvector,HPLJETlinetype,HPLJETlrput_text,
  2159. X        HPLJETulput_text, line_and_point}
  2160. X    ,{"laserjet3",HPLJETXMAX,HPLJETYMAX,HPLJET3VCHAR, HPLJET3HCHAR, HPLJETVTIC, 
  2161. X        HPLJETHTIC, HPLJET3init,HPLJETreset, HPLJETtext, HPLJETgraphics, 
  2162. X        HPLJETmove, HPLJETvector,HPLJETlinetype,HPLJETlrput_text,
  2163. X        HPLJETulput_text, line_and_point}
  2164. X#endif
  2165. X
  2166. X#ifdef PC
  2167. X#ifdef __TURBOC__
  2168. X
  2169. X    ,{"egalib", EGALIB_XMAX, EGALIB_YMAX, EGALIB_VCHAR, EGALIB_HCHAR,
  2170. X        EGALIB_VTIC, EGALIB_HTIC, EGALIB_init, EGALIB_reset,
  2171. X        EGALIB_text, EGALIB_graphics, EGALIB_move, EGALIB_vector,
  2172. X        EGALIB_linetype, EGALIB_lrput_text, EGALIB_ulput_text, line_and_point}
  2173. X
  2174. X    ,{"vgalib", VGA_XMAX, VGA_YMAX, VGA_VCHAR, VGA_HCHAR,
  2175. X        VGA_VTIC, VGA_HTIC, VGA_init, VGA_reset,
  2176. X        VGA_text, VGA_graphics, VGA_move, VGA_vector,
  2177. X        VGA_linetype, VGA_lrput_text, VGA_ulput_text, line_and_point}
  2178. X
  2179. X    ,{"vgamono", VGA_XMAX, VGA_YMAX, VGA_VCHAR, VGA_HCHAR,
  2180. X        VGA_VTIC, VGA_HTIC, VGA_init, VGA_reset,
  2181. X        VGA_text, VGA_graphics, VGA_move, VGA_vector,
  2182. X        VGAMONO_linetype, VGA_lrput_text, VGA_ulput_text, line_and_point}
  2183. X
  2184. X    ,{"mcga", MCGA_XMAX, MCGA_YMAX, MCGA_VCHAR, MCGA_HCHAR,
  2185. X        MCGA_VTIC, MCGA_HTIC, MCGA_init, MCGA_reset,
  2186. X        MCGA_text, MCGA_graphics, MCGA_move, MCGA_vector,
  2187. X        MCGA_linetype, MCGA_lrput_text, MCGA_ulput_text, line_and_point}
  2188. X
  2189. X    ,{"cga", CGA_XMAX, CGA_YMAX, CGA_VCHAR, CGA_HCHAR,
  2190. X        CGA_VTIC, CGA_HTIC, CGA_init, CGA_reset,
  2191. X        CGA_text, CGA_graphics, CGA_move, CGA_vector,
  2192. X        CGA_linetype, CGA_lrput_text, CGA_ulput_text, line_and_point}
  2193. X
  2194. X    ,{"hercules", HERC_XMAX, HERC_YMAX, HERC_VCHAR, HERC_HCHAR,
  2195. X        HERC_VTIC, HERC_HTIC, HERC_init, HERC_reset,
  2196. X        HERC_text, HERC_graphics, HERC_move, HERC_vector,
  2197. X        HERC_linetype, HERC_lrput_text, HERC_ulput_text, line_and_point}
  2198. X
  2199. X#else
  2200. X    ,{"cga", CGA_XMAX, CGA_YMAX, CGA_VCHAR, CGA_HCHAR,
  2201. X        CGA_VTIC, CGA_HTIC, CGA_init, CGA_reset,
  2202. X        CGA_text, CGA_graphics, CGA_move, CGA_vector,
  2203. X        CGA_linetype, CGA_lrput_text, CGA_ulput_text, line_and_point}
  2204. X
  2205. X    ,{"egabios", EGA_XMAX, EGA_YMAX, EGA_VCHAR, EGA_HCHAR,
  2206. X        EGA_VTIC, EGA_HTIC, EGA_init, EGA_reset,
  2207. X        EGA_text, EGA_graphics, EGA_move, EGA_vector,
  2208. X        EGA_linetype, EGA_lrput_text, EGA_ulput_text, do_point}
  2209. X
  2210. X#ifdef EGALIB
  2211. X    ,{"egalib", EGALIB_XMAX, EGALIB_YMAX, EGALIB_VCHAR, EGALIB_HCHAR,
  2212. X        EGALIB_VTIC, EGALIB_HTIC, EGALIB_init, EGALIB_reset,
  2213. X        EGALIB_text, EGALIB_graphics, EGALIB_move, EGALIB_vector,
  2214. X        EGALIB_linetype, EGALIB_lrput_text, EGALIB_ulput_text, do_point}
  2215. X#endif
  2216. X
  2217. X#ifdef HERCULES
  2218. X    ,{"hercules", HERC_XMAX, HERC_YMAX, HERC_VCHAR, HERC_HCHAR,
  2219. X        HERC_VTIC, HERC_HTIC, HERC_init, HERC_reset,
  2220. X        HERC_text, HERC_graphics, HERC_move, HERC_vector,
  2221. X        HERC_linetype, HERC_lrput_text, HERC_ulput_text, line_and_point}
  2222. X#endif /* HERCULES */
  2223. X
  2224. X#ifdef ATT6300
  2225. X    ,{"att", ATT_XMAX, ATT_YMAX, ATT_VCHAR, ATT_HCHAR,
  2226. X        ATT_VTIC, ATT_HTIC, ATT_init, ATT_reset,
  2227. X        ATT_text, ATT_graphics, ATT_move, ATT_vector,
  2228. X        ATT_linetype, ATT_lrput_text, ATT_ulput_text, line_and_point}
  2229. X#endif
  2230. X
  2231. X#ifdef CORONA
  2232. X    ,{"corona325", COR_XMAX, COR_YMAX, COR_VCHAR, COR_HCHAR,
  2233. X        COR_VTIC, COR_HTIC, COR_init, COR_reset,
  2234. X        COR_text, COR_graphics, COR_move, COR_vector,
  2235. X        COR_linetype, COR_lrput_text, COR_ulput_text, line_and_point}
  2236. X#endif /* CORONA */
  2237. X#endif /* TURBOC */
  2238. X#endif /* PC */
  2239. X
  2240. X#ifdef AED
  2241. X    ,{"aed512", AED5_XMAX, AED_YMAX, AED_VCHAR, AED_HCHAR,
  2242. X        AED_VTIC, AED_HTIC, AED_init, AED_reset, 
  2243. X        AED_text, AED_graphics, AED_move, AED_vector, 
  2244. X        AED_linetype, AED5_lrput_text, AED_ulput_text, do_point}
  2245. X    ,{"aed767", AED_XMAX, AED_YMAX, AED_VCHAR, AED_HCHAR,
  2246. X        AED_VTIC, AED_HTIC, AED_init, AED_reset, 
  2247. X        AED_text, AED_graphics, AED_move, AED_vector, 
  2248. X        AED_linetype, AED_lrput_text, AED_ulput_text, do_point}
  2249. X#endif
  2250. X
  2251. X#ifdef UNIXPC
  2252. X    ,{"unixpc",uPC_XMAX,uPC_YMAX,uPC_VCHAR, uPC_HCHAR, uPC_VTIC, 
  2253. X        uPC_HTIC, uPC_init,uPC_reset, uPC_text, uPC_graphics, 
  2254. X        uPC_move, uPC_vector,uPC_linetype,uPC_lrput_text,
  2255. X        uPC_ulput_text, line_and_point}
  2256. X#endif
  2257. X
  2258. X#ifdef BITGRAPH
  2259. X    ,{"bitgraph",BG_XMAX,BG_YMAX,BG_VCHAR, BG_HCHAR, BG_VTIC, 
  2260. X        BG_HTIC, BG_init,BG_reset, BG_text, BG_graphics, 
  2261. X        BG_move, BG_vector,BG_linetype,BG_lrput_text,
  2262. X        BG_ulput_text, line_and_point}
  2263. X#endif
  2264. X
  2265. X#ifdef HP26
  2266. X    ,{"hp2623A",HP26_XMAX,HP26_YMAX, HP26_VCHAR, HP26_HCHAR,HP26_VTIC,HP26_HTIC,
  2267. X        HP26_init,HP26_reset,HP26_text, HP26_graphics, HP26_move, HP26_vector,
  2268. X        HP26_linetype, HP26_lrput_text, HP26_ulput_text, line_and_point}
  2269. X#endif
  2270. X
  2271. X#ifdef HP75
  2272. X    ,{"hp7580B",HP75_XMAX,HP75_YMAX, HP75_VCHAR, HP75_HCHAR,HP75_VTIC,HP75_HTIC,
  2273. X        HP75_init,HP75_reset,HP75_text, HP75_graphics, HP75_move, HP75_vector,
  2274. X        HP75_linetype, HP75_lrput_text, HP75_ulput_text, do_point}
  2275. X#endif
  2276. X
  2277. X#ifdef IRIS4D
  2278. X    ,{"iris4d", IRIS4D_XMAX, IRIS4D_YMAX, IRIS4D_VCHAR,
  2279. X        IRIS4D_HCHAR, IRIS4D_VTIC, IRIS4D_HTIC,
  2280. X        IRIS4D_init, IRIS4D_reset, IRIS4D_text,
  2281. X        IRIS4D_graphics, IRIS4D_move, IRIS4D_vector,
  2282. X        IRIS4D_linetype, IRIS4D_lrput_text, IRIS4D_ulput_text,
  2283. X        do_point}
  2284. X#endif
  2285. X
  2286. X#ifdef POSTSCRIPT
  2287. X    ,{"postscript", PS_XMAX, PS_YMAX, PS_VCHAR, PS_HCHAR, PS_VTIC, PS_HTIC,
  2288. X        PS_init, PS_reset, PS_text, PS_graphics, PS_move, PS_vector,
  2289. X        PS_linetype, PS_lrput_text, PS_ulput_text, line_and_point}
  2290. X#endif
  2291. X
  2292. X#ifdef QMS
  2293. X    ,{"qms",QMS_XMAX,QMS_YMAX, QMS_VCHAR, QMS_HCHAR, QMS_VTIC, QMS_HTIC,
  2294. X        QMS_init,QMS_reset, QMS_text, QMS_graphics, QMS_move, QMS_vector,
  2295. X        QMS_linetype,QMS_lrput_text,QMS_ulput_text,line_and_point}
  2296. X#endif
  2297. X
  2298. X#ifdef REGIS
  2299. X    ,{"regis", REGISXMAX, REGISYMAX, REGISVCHAR, REGISHCHAR, REGISVTIC,
  2300. X        REGISHTIC, REGISinit, REGISreset, REGIStext, REGISgraphics,
  2301. X        REGISmove,REGISvector,REGISlinetype, REGISlrput_text, REGISulput_text,
  2302. X        line_and_point}
  2303. X#endif
  2304. X
  2305. X
  2306. X#ifdef SELANAR
  2307. X    ,{"selanar",TEK40XMAX,TEK40YMAX,TEK40VCHAR, TEK40HCHAR, TEK40VTIC, 
  2308. X        TEK40HTIC, SEL_init, SEL_reset, SEL_text, SEL_graphics, 
  2309. X        TEK40move, TEK40vector, TEK40linetype, TEK40lrput_text,
  2310. X        TEK40ulput_text, line_and_point}
  2311. X#endif
  2312. X
  2313. X#ifdef TEK
  2314. X    ,{"tek40xx",TEK40XMAX,TEK40YMAX,TEK40VCHAR, TEK40HCHAR, TEK40VTIC, 
  2315. X        TEK40HTIC, TEK40init, TEK40reset, TEK40text, TEK40graphics, 
  2316. X        TEK40move, TEK40vector, TEK40linetype, TEK40lrput_text,
  2317. X        TEK40ulput_text, line_and_point}
  2318. X#endif
  2319. X
  2320. X#ifdef UNIXPLOT
  2321. X    ,{"unixplot", UP_XMAX, UP_YMAX, UP_VCHAR, UP_HCHAR, UP_VTIC, UP_HTIC,
  2322. X        UP_init, UP_reset, UP_text, UP_graphics, UP_move, UP_vector,
  2323. X        UP_linetype, UP_lrput_text, UP_ulput_text, line_and_point}
  2324. X#endif
  2325. X
  2326. X#ifdef V384
  2327. X    ,{"vx384", V384_XMAX, V384_YMAX, V384_VCHAR, V384_HCHAR, V384_VTIC,
  2328. X        V384_HTIC, V384_init, V384_reset, V384_text, V384_graphics,
  2329. X        V384_move, V384_vector, V384_linetype, V384_lrput_text,
  2330. X        V384_ulput_text, do_point}
  2331. X#endif
  2332. X    };
  2333. X
  2334. X#define TERMCOUNT (sizeof(term_tbl)/sizeof(struct termentry))
  2335. X
  2336. X
  2337. Xlist_terms()
  2338. X{
  2339. Xregister int i;
  2340. X
  2341. X    fprintf(stderr,"\navailable terminals types:\n");
  2342. X    for (i = 0; i < TERMCOUNT; i++)
  2343. X        fprintf(stderr,"\t%s\n",term_tbl[i].name);
  2344. X    (void) putc('\n',stderr);
  2345. X}
  2346. X
  2347. X
  2348. Xset_term(c_token)
  2349. Xint c_token;
  2350. X{
  2351. Xregister int i,t;
  2352. X
  2353. X    if (!token[c_token].is_token)
  2354. X        int_error("terminal name expected",c_token);
  2355. X    t = -1;
  2356. X
  2357. X    for (i = 0; i < TERMCOUNT; i++) {
  2358. X           if (!strncmp(input_line + token[c_token].start_index,term_tbl[i].name,
  2359. X            token[c_token].length)) {
  2360. X            if (t != -1)
  2361. X                int_error("ambiguous terminal name",c_token);
  2362. X            t = i;
  2363. X        }
  2364. X    }
  2365. X    if (t == -1)
  2366. X        int_error("unknown terminal type; type just 'set terminal' for a list",
  2367. X            c_token);
  2368. X    else if (!strncmp("unixplot",term_tbl[t].name,sizeof(unixplot))) {
  2369. X        UP_redirect (2);  /* Redirect actual stdout for unixplots */
  2370. X    }
  2371. X    else if (unixplot) {
  2372. X        UP_redirect (3);  /* Put stdout back together again. */
  2373. X    }
  2374. X    term_init = FALSE;
  2375. X    return(t);
  2376. X}
  2377. X
  2378. X
  2379. X/*
  2380. X   Routine to detect what terminal is being used (or do anything else
  2381. X   that would be nice).  One anticipated (or allowed for) side effect
  2382. X   is that the global ``term'' may be set.
  2383. X*/
  2384. Xinit()
  2385. X{
  2386. Xchar *term_name = NULL;
  2387. Xint t = -1, i;
  2388. X#ifdef __TURBOC__
  2389. X  int g_driver,g_mode;
  2390. X  char far *c1,*c2;
  2391. X
  2392. X/* Some of this code including BGI drivers is copyright Borland Intl. */
  2393. X    g_driver=DETECT;
  2394. X          get_path();
  2395. X        initgraph(&g_driver,&g_mode,path);
  2396. X        c1=getdrivername();
  2397. X        c2=getmodename(g_mode);
  2398. X          switch (g_driver){
  2399. X            case -2: fprintf(stderr,"Graphics card not detected.\n");
  2400. X                     break;
  2401. X            case -3: fprintf(stderr,"BGI driver file cannot be found.\n");
  2402. X                     break;
  2403. X            case -4: fprintf(stderr,"Invalid BGI driver file.\n");
  2404. X                     break;
  2405. X            case -5: fprintf(stderr,"Insufficient memory to load ",
  2406. X                             "graphics driver.");
  2407. X                     break;
  2408. X            }
  2409. X        closegraph();
  2410. X    fprintf(stderr,"\tTC Graphics, driver %s  mode %s\n",c1,c2);
  2411. X#endif
  2412. X#ifdef VMS
  2413. X/*
  2414. X   Determine if we have a regis terminal.  If not use TERM 
  2415. X   (tek40xx) as default.
  2416. X*/
  2417. X#include <descrip>
  2418. X#include <dvidef>
  2419. X
  2420. Xextern int term;
  2421. Xchar *term_str="tt:";
  2422. Xtypedef struct
  2423. X          {
  2424. X          short cond_value;
  2425. X          short count;
  2426. X          int info;
  2427. X          }  status_block;
  2428. Xtypedef struct
  2429. X          {
  2430. X          short buffer_len;
  2431. X          short item_code;
  2432. X          int buffer_addr;
  2433. X          int ret_len_addr;
  2434. X          }  item_desc;
  2435. Xstruct {
  2436. X    item_desc dev_type;
  2437. X      int terminator;
  2438. X   }  dvi_list;
  2439. X   int status, dev_type, zero=0;
  2440. X   char buffer[255];
  2441. X   $DESCRIPTOR(term_desc, term_str);
  2442. X
  2443. X/* set up dvi item list */
  2444. X    dvi_list.dev_type.buffer_len = 4;
  2445. X    dvi_list.dev_type.item_code = DVI$_TT_REGIS;
  2446. X    dvi_list.dev_type.buffer_addr = &dev_type;
  2447. X    dvi_list.dev_type.ret_len_addr = 0;
  2448. X
  2449. X    dvi_list.terminator = 0;
  2450. X
  2451. X/* See what type of terminal we have. */
  2452. X    status = SYS$GETDVIW (0, 0, &term_desc, &dvi_list, 0, 0, 0, 0);
  2453. X    if ((status & 1) && dev_type) {
  2454. X        term_name = "regis";
  2455. X    }
  2456. X#endif
  2457. X    if (term_name != NULL) {
  2458. X    /* We have a name to set! */
  2459. X        for (i = 0; i < TERMCOUNT; i++) {
  2460. X               if (!strncmp("regis",term_tbl[i].name,5)) {
  2461. X                t = i;
  2462. X            }
  2463. X        }
  2464. X        if (t != -1)
  2465. X            term = t;
  2466. X    }
  2467. X}
  2468. X
  2469. X
  2470. X/*
  2471. X    This is always defined so we don't have to have command.c know if it
  2472. X    is there or not.
  2473. X*/
  2474. X#ifndef UNIXPLOT
  2475. XUP_redirect(caller) int caller; {}
  2476. X#else
  2477. XUP_redirect (caller)
  2478. Xint caller;
  2479. X/*
  2480. X    Unixplot can't really write to outfile--it wants to write to stdout.
  2481. X    This is normally ok, but the original design of gnuplot gives us
  2482. X    little choice.  Originally users of unixplot had to anticipate
  2483. X    their needs and redirect all I/O to a file...  Not very gnuplot-like.
  2484. X
  2485. X    caller:  1 - called from SET OUTPUT "FOO.OUT"
  2486. X             2 - called from SET TERM UNIXPLOT
  2487. X             3 - called from SET TERM other
  2488. X             4 - called from SET OUTPUT
  2489. X*/
  2490. X{
  2491. X    switch (caller) {
  2492. X    case 1:
  2493. X    /* Don't save, just replace stdout w/outfile (save was already done). */
  2494. X        if (unixplot)
  2495. X            *(stdout) = *(outfile);  /* Copy FILE structure */
  2496. X    break;
  2497. X    case 2:
  2498. X        if (!unixplot) {
  2499. X            fflush(stdout);
  2500. X            save_stdout = *(stdout);
  2501. X            *(stdout) = *(outfile);  /* Copy FILE structure */
  2502. X            unixplot = 1;
  2503. X        }
  2504. X    break;
  2505. X    case 3:
  2506. X    /* New terminal in use--put stdout back to original. */
  2507. X        closepl();
  2508. X        fflush(stdout);
  2509. X        *(stdout) = save_stdout;  /* Copy FILE structure */
  2510. X        unixplot = 0;
  2511. X    break;
  2512. X    case 4:
  2513. X    /*  User really wants to go to normal output... */
  2514. X        if (unixplot) {
  2515. X            fflush(stdout);
  2516. X            *(stdout) = save_stdout;  /* Copy FILE structure */
  2517. X        }
  2518. X    break;
  2519. X    }
  2520. X}
  2521. X#endif
  2522. END_OF_FILE
  2523. if test 19496 -ne `wc -c <'term.c'`; then
  2524.     echo shar: \"'term.c'\" unpacked with wrong size!
  2525. fi
  2526. # end of 'term.c'
  2527. fi
  2528. echo shar: End of archive 4 \(of 7\).
  2529. cp /dev/null ark4isdone
  2530. MISSING=""
  2531. for I in 1 2 3 4 5 6 7 ; do
  2532.     if test ! -f ark${I}isdone ; then
  2533.     MISSING="${MISSING} ${I}"
  2534.     fi
  2535. done
  2536. if test "${MISSING}" = "" ; then
  2537.     echo You have unpacked all 7 archives.
  2538.     rm -f ark[1-9]isdone
  2539. else
  2540.     echo You still need to unpack the following archives:
  2541.     echo "        " ${MISSING}
  2542. fi
  2543. ##  End of shell archive.
  2544. exit 0
  2545.